- 浏览: 36036 次
最新评论
-
sp42:
douban
一个通用分页查询方法 -
qq330749800:
可以共享一下破解后的JAR包吗,或者源码。
java生成excel的曲线图,大家都用什么免费组件? -
lfrick:
将第22行改为:'<thead><tr cl ...
ext2中grid滚动条问题(已解决) -
xiaolait31:
你好,我用了你的文件,还是没成功,能不能具体说下,修改了什么地 ...
ext2中grid滚动条问题(已解决) -
miss4813:
这是Ext2.2 的一个BUG;
Ext2.3中已经解决这个 ...
ext2中grid滚动条问题(已解决)
花了2个小时终于配置好struts2.0.6+spring2.0.3+hibernane3,为自己庆祝一下,分享一下经验
一、struts2。
跟webwork配置基本一致,主要是struts2.properties和struts.xml 2个配置文件,我的struts2.properties如下配置:
struts2.properties
- struts.tag.altSyntax = true
- struts.devMode = true
- ### These can be used to set the default HTTP and HTTPS ports
- struts.url.http.port = 80
- #webwork.url.https.port = 443
- ### This can be used to set your locale and encoding scheme
- struts.custom.i18n.resources=ApplicationResources
- struts.locale=zh_CN
- struts.i18n.encoding=utf-8
- # uses javax.servlet.context.tempdir by default
- struts.multipart.parser=com.opensymphony.webwork.dispatcher.multipart.PellMultiPartRequest
- #struts.multipart.saveDir=tmp
- struts.multipart.saveDir=/tmp
- struts.multipart.maxSize=512000000
- struts.configuration.xml.reload=true
- struts.objectFactory = spring
struts.xml 就是配置action了,由于设定了struts.objectFactory = spring,因此struts2会自动将action转为spring的bean,struts.xml可以直接配置我们的action路径,在action中我们只需要设置某个service文件的set方法即可调用事务管理bean。
struts.xml
- <!---->xml version="1.0" encoding="UTF-8" ?>
- <!---->
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <include file="struts-default.xml" />
- <package name="default" extends="struts-default">
- <default-interceptor-ref name="completeStack" />
- <global-results>
- <result name="login" type="redirect">login!default.actionresult>
- <result name="unauthorized">unauthorized.jspresult>
- global-results>
- <action name="login" class="com.baseframe.action.LoginAction">
- <result name="input">login.jspresult>
- <result name="success">main.jspresult>
- <result name="error">login.jspresult>
- action>
- <action name="logout" class="com.baseframe.action.LogoutAction">
- <result name="success">login.jspresult>
- action>
- package>
- struts>
二、spring2。
添加dist下的3个spring包,因为不知道哪些包是必须的,把lib里的包都加了,去除jakarta-commons/commons-attributes-compiler.jar、j2ee/servlet-api.jar、j2ee/jsp-api.jar,然后建立配置文件,我分了三个文件:
主配置文件
- <!---->xml version="1.0" encoding="UTF-8"?>
- <!---->
- "http://www.springframework.org/dtd/spring-beans.dtd">
- <beans>
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- ...
- bean>
- <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
- ...
- bean>
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <property name="hibernateProperties">
- <ref bean="hibernateProperties"/>
- property>
- <property name="mappingResources">
- <list>
- <value>com/baseframe/model/AppUser.hbm.xmlvalue>
- <!---->
- list>
- property>
- bean>
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory"/>
- bean>
- <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
- <property name="transactionManager" ref="transactionManager"/>
- <property name="transactionAttributes">
- <props>
- <prop key="*">PROPAGATION_REQUIREDprop>
- <prop key="amount*">PROPAGATION_REQUIRED,readOnlyprop>
- <prop key="find*">PROPAGATION_REQUIRED,readOnlyprop>
- props>
- property>
- bean>
- <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
- <property name="beanNames">
- <value>*Servicevalue>
- property>
- <property name="interceptorNames">
- <list>
- <value>transactionInterceptorvalue>
- <!---->
- list>
- property>
- bean>
- <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
- <property name="transactionInterceptor" ref="transactionInterceptor"/>
- bean>
- beans>
dao配置文件
- <!---->xml version="1.0" encoding="UTF-8"?>
- <!---->
- "http://www.springframework.org/dtd/spring-beans.dtd">
- <beans default-autowire="byName">
- <bean id="userDao" class="com.baseframe.dao.impl.UserDaoImpl"/>
- beans>
service/manager配置
- <!---->xml version="1.0" encoding="UTF-8"?>
- <!---->
- "http://www.springframework.org/dtd/spring-beans.dtd">
- <beans default-autowire="byName">
- <bean id="userService" class="com.baseframe.service.impl.UserServiceImpl"/>
- beans>
三、web.xml
有一点很重要,struts的filter需要放在最底,不然action接收的中文可能会乱码,不知道是不是这个原因,反正配置了就没有乱码了,加上org.springframework.orm.hibernate3.support.OpenSessionInViewFilter就不用考虑hibernate的lazy问题了:
xml 代码
- <filter>
- <filter-name>encodingFilterfilter-name>
- <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
- <init-param>
- <param-name>encodingparam-name>
- <param-value>UTF-8param-value>
- init-param>
- filter>
- <filter-mapping>
- <filter-name>encodingFilterfilter-name>
- <url-pattern>/*url-pattern>
- filter-mapping>
- <filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- <filter>
- extremetable的filter
- filter>
- <filter-mapping>
- extremetable的filter mapping
- filter-mapping>
- <filter>
- <filter-name>struts2filter-name>
- <filter-class>org.apache.struts2.dispatcher.FilterDispatcherfilter-class>
- filter>
- <filter-mapping>
- <filter-name>struts2filter-name>
- <url-pattern>/*url-pattern>
- filter-mapping>
如有错误,欢迎指正
评论
9 楼
xugq035
2007-03-29
<br/>
<strong>gcgan 写道:</strong><br/>
<div class='quote_div'>struts.xml
<div class='quote_div'><font>
<div class='dp-highlighter' style='width: 99%; height: 236px;'>
<div class='bar'> </div>
<ol class='dp-xml'>
<li class='alt'><span><span class='tag'><!----><span class='tag-name'>xml</span><span> </span><span class='attribute'>version</span><span>=</span><span class='attribute-value'>"1.0"</span><span> </span><span class='attribute'>encoding</span><span>=</span><span class='attribute-value'>"UTF-8"</span><span> </span><span class='tag'>?></span><span> </span></span> </span></li>
<li class=''><span><!----></span></li>
<li class='alt'><span> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" </span> </li>
<li class=''><span> "http://struts.apache.org/dtds/struts-2.0.dtd"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><</span><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>include</span><span> </span><span class='attribute'>file</span><span>=</span><span class='attribute-value'>"struts-default.xml"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>package</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"default"</span><span> </span><span class='attribute'>extends</span><span>=</span><span class='attribute-value'>"struts-default"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>default-interceptor-ref</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"completeStack"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class=''><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>type</span><span>=</span><span class='attribute-value'>"redirect"</span><span class='tag'>></span><span>login!default.action</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"unauthorized"</span><span class='tag'>></span><span>unauthorized.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LoginAction"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"input"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>main.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"error"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"logout"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LogoutAction"</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>package</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </span></li>
</ol>
</div>
</font><br/>
</div>
<action></action>的class是用的类<font>如:<span class='attribute-value'>com.baseframe.action.LoginAction</span></font>,请问什么地方体现了struts+spring呢?<br/>
我觉得是不是应该用spring的bean来代替类呢?<br/>
</div>
<p>spring的bean应该在action中调用,在LoginAction中应该包含类似如下的代码:</p>
<p><font><font> private EmployeeService employeeService;<br/>
public void setEmployeeService(EmployeeService employeeService) {<br/>
this.employeeService = employeeService;<br/>
}</font></font><br/>
</p>
<p>这个EmployeeService才是spring的bean<br/>
只要你再struts.properties文件中设定了<font>struts.objectFactory = spring,加入<font>struts2-spring-plugin-2.0.6.jar就可以了</font></font></p>
<strong>gcgan 写道:</strong><br/>
<div class='quote_div'>struts.xml
<div class='quote_div'><font>
<div class='dp-highlighter' style='width: 99%; height: 236px;'>
<div class='bar'> </div>
<ol class='dp-xml'>
<li class='alt'><span><span class='tag'><!----><span class='tag-name'>xml</span><span> </span><span class='attribute'>version</span><span>=</span><span class='attribute-value'>"1.0"</span><span> </span><span class='attribute'>encoding</span><span>=</span><span class='attribute-value'>"UTF-8"</span><span> </span><span class='tag'>?></span><span> </span></span> </span></li>
<li class=''><span><!----></span></li>
<li class='alt'><span> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" </span> </li>
<li class=''><span> "http://struts.apache.org/dtds/struts-2.0.dtd"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><</span><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>include</span><span> </span><span class='attribute'>file</span><span>=</span><span class='attribute-value'>"struts-default.xml"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>package</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"default"</span><span> </span><span class='attribute'>extends</span><span>=</span><span class='attribute-value'>"struts-default"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>default-interceptor-ref</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"completeStack"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class=''><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>type</span><span>=</span><span class='attribute-value'>"redirect"</span><span class='tag'>></span><span>login!default.action</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"unauthorized"</span><span class='tag'>></span><span>unauthorized.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LoginAction"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"input"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>main.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"error"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"logout"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LogoutAction"</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>package</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </span></li>
</ol>
</div>
</font><br/>
</div>
<action></action>的class是用的类<font>如:<span class='attribute-value'>com.baseframe.action.LoginAction</span></font>,请问什么地方体现了struts+spring呢?<br/>
我觉得是不是应该用spring的bean来代替类呢?<br/>
</div>
<p>spring的bean应该在action中调用,在LoginAction中应该包含类似如下的代码:</p>
<p><font><font> private EmployeeService employeeService;<br/>
public void setEmployeeService(EmployeeService employeeService) {<br/>
this.employeeService = employeeService;<br/>
}</font></font><br/>
</p>
<p>这个EmployeeService才是spring的bean<br/>
只要你再struts.properties文件中设定了<font>struts.objectFactory = spring,加入<font>struts2-spring-plugin-2.0.6.jar就可以了</font></font></p>
8 楼
gcgan
2007-03-29
struts.xml
<div class='quote_div'><font>
<div class='dp-highlighter' style='width: 99%; height: 236px;'>
<div class='bar'> </div>
<ol class='dp-xml'>
<li class='alt'><span><span class='tag'><!----><span class='tag-name'>xml</span><span> </span><span class='attribute'>version</span><span>=</span><span class='attribute-value'>"1.0"</span><span> </span><span class='attribute'>encoding</span><span>=</span><span class='attribute-value'>"UTF-8"</span><span> </span><span class='tag'>?></span><span> </span></span> </span></li>
<li class=''><span><!----></span></li>
<li class='alt'><span> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" </span> </li>
<li class=''><span> "http://struts.apache.org/dtds/struts-2.0.dtd"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><</span><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>include</span><span> </span><span class='attribute'>file</span><span>=</span><span class='attribute-value'>"struts-default.xml"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>package</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"default"</span><span> </span><span class='attribute'>extends</span><span>=</span><span class='attribute-value'>"struts-default"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>default-interceptor-ref</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"completeStack"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class=''><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>type</span><span>=</span><span class='attribute-value'>"redirect"</span><span class='tag'>></span><span>login!default.action</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"unauthorized"</span><span class='tag'>></span><span>unauthorized.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LoginAction"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"input"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>main.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"error"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"logout"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LogoutAction"</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>package</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </span></li>
</ol>
</div>
</font><br/>
</div>
<action>的class是用的类<font>如:<span class='attribute-value'>com.baseframe.action.LoginAction</span></font>,请问什么地方体现了struts+spring呢?<br/>
我觉得是不是应该用spring的bean来代替类呢?<br/>
<br/>
</action>
<div class='quote_div'><font>
<div class='dp-highlighter' style='width: 99%; height: 236px;'>
<div class='bar'> </div>
<ol class='dp-xml'>
<li class='alt'><span><span class='tag'><!----><span class='tag-name'>xml</span><span> </span><span class='attribute'>version</span><span>=</span><span class='attribute-value'>"1.0"</span><span> </span><span class='attribute'>encoding</span><span>=</span><span class='attribute-value'>"UTF-8"</span><span> </span><span class='tag'>?></span><span> </span></span> </span></li>
<li class=''><span><!----></span></li>
<li class='alt'><span> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" </span> </li>
<li class=''><span> "http://struts.apache.org/dtds/struts-2.0.dtd"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><</span><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>include</span><span> </span><span class='attribute'>file</span><span>=</span><span class='attribute-value'>"struts-default.xml"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>package</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"default"</span><span> </span><span class='attribute'>extends</span><span>=</span><span class='attribute-value'>"struts-default"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>default-interceptor-ref</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"completeStack"</span><span> </span><span class='tag'>/></span><span> </span> </li>
<li class=''><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>type</span><span>=</span><span class='attribute-value'>"redirect"</span><span class='tag'>></span><span>login!default.action</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"unauthorized"</span><span class='tag'>></span><span>unauthorized.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>global-results</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"login"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LoginAction"</span><span class='tag'>></span><span> </span> </li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"input"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>main.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"error"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><</span><span class='tag-name'>action</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"logout"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"com.baseframe.action.LogoutAction"</span><span class='tag'>></span><span> </span> </li>
<li class=''><span> </span><span class='tag'><</span><span class='tag-name'>result</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"success"</span><span class='tag'>></span><span>login.jsp</span><span class='tag'><span class='tag-name'>result</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span><span class='tag'><span class='tag-name'>action</span><span class='tag'>></span><span> </span> </span></li>
<li class=''><span> </span><span class='tag'><span class='tag-name'>package</span><span class='tag'>></span><span> </span> </span></li>
<li class='alt'><span> </span> </li>
<li class=''><span/><span class='tag'><span class='tag-name'>struts</span><span class='tag'>></span><span> </span> </span></li>
</ol>
</div>
</font><br/>
</div>
<action>的class是用的类<font>如:<span class='attribute-value'>com.baseframe.action.LoginAction</span></font>,请问什么地方体现了struts+spring呢?<br/>
我觉得是不是应该用spring的bean来代替类呢?<br/>
<br/>
</action>
7 楼
xugq035
2007-03-24
javachs 写道
老兄,是不是要用tomcat5.5以上版本才支持struts2呀
我用的是tomcat6.0,应该5.5也没问题的,struts有个j4的包,可以支持jdk1.4,不过我没试过
6 楼
xugq035
2007-03-24
roundlight 写道
非常感谢 xugq035 的介绍资料,我也想搞个 struts + spring + hibernate 相结合的东西出来, 不知道 这位朋友,能不能给我做一下指导啊,再这里 先谢过了啊
如果,有机会的话,像你学习啊
如果,有机会的话,像你学习啊
共同学习,struts2是个好东西,要摸透它需要时间,不过这段时间公司任务比较多,顾不上这个,有机会交流一下
5 楼
javachs
2007-03-23
老兄,是不是要用tomcat5.5以上版本才支持struts2呀
4 楼
roundlight
2007-03-22
非常感谢 xugq035 的介绍资料,我也想搞个 struts + spring + hibernate 相结合的东西出来, 不知道 这位朋友,能不能给我做一下指导啊,再这里 先谢过了啊
如果,有机会的话,像你学习啊
如果,有机会的话,像你学习啊
3 楼
javaChicken
2007-03-22
hibernat呢?,你是帅哥,都不快点把这个东西写完整
2 楼
xugq035
2007-03-20
环境搭建基本上就是这样了,再详细等我研究下再说了
1 楼
祁兴明
2007-03-20
太好了 我正需要这个东东呢 您能写的更详细一点那就更好了 thank you!
相关推荐
### Struts2.0.6配置 Struts2作为MVC框架的一部分,主要负责处理Web层的请求与响应。其核心配置文件`struts.xml`和`struts.properties`定义了框架的行为与动作映射。 #### `struts.properties`关键配置解析: - *...
这是一个基于经典的Java Web技术栈构建的图书管理系统,利用了Tomcat5.5作为应用服务器,Struts2作为MVC框架,Spring2.0.6负责依赖注入和事务管理,而Hibernate3则作为对象关系映射(ORM)工具,用于数据库操作。...
Struts1.2.9、Spring2.0.6和Hibernate3.0.5是Java Web开发中的三个重要框架,它们的整合应用是早期企业级应用程序的常见实践。这个例子展示了如何将这三个框架集成在一起,以实现高效、灵活的MVC(模型-视图-控制器...
现在就将笔者使用Myeclipse工具应用struts2 + spring2 + hibernate3 实现CRUD操作的步骤一一纪录下来,为初学者少走弯路略尽绵薄之力!在本文中,笔者将Struts2.0.6、Spring2.0.6和Hibernate3.1进行整合,希望通过...
最流行技术Struts2.1 +Spring 2.5.1+ibatis2.3整合开发而成,这与我以前发布的版本中最大特色是整合了Spring2.5.1中的注解功能和半自动化工具ibatis技术,这是本示例的两大特色,简化了配置文件的烦锁,希望能给更多喜欢...
2. **启用Struts2-Spring插件**:在Struts2的配置文件(struts.xml)中启用Struts2-Spring插件,以便让Struts2知道如何与Spring容器交互。 3. **创建自定义拦截器**:为了更好地利用Spring的功能,可能还需要创建...
本文将详细介绍如何配置新版SSH+DWR框架,即Struts2.1.8、Spring3.0和Hibernate3.3.2与Direct Web Remoting (DWR) 2.0.6的集成。这个配置示例是基于目前最新的技术栈,旨在提供一个高效、稳定的开发环境。 首先,...
现在就将笔者使用Myeclipse工具应用struts2 + spring2 + hibernate3 实现CRUD操作的步骤一一纪录下来,为初学者少走弯路略尽绵薄之力!在本文中,笔者将Struts2.0.6、Spring2.0.6和Hibernate3.1进行整合,希望通过...
根据提供的文件信息,本文将详细解析“Struts2 + Spring2 + Hibernate3”技术栈的集成与应用。本文主要从项目准备、环境搭建、公共类的设计等方面进行深入讲解。 ### 一、项目背景及意义 Struts2、Spring2 和 ...
### 最新版本Struts2.1.8+Spring3.0+Hibernate3.3.2+DWR2.0.6配置详解 在本篇内容中,我们将详细探讨如何搭建一个基于Struts2.1.8、Spring3.0、Hibernate3.3.2以及DWR2.0.6的Web应用程序框架。这一组合被称为SSH+...
Spring2.0.6的引入则提供了对Struts2的集成支持,可以通过Spring的Action代理来管理Action实例,实现依赖注入。Hibernate3.1则负责数据持久化,通过配置映射文件(XML或注解)将Java对象与数据库表关联。 在整合的...
3. **配置pom.xml**:在新创建的项目中,编辑pom.xml文件,添加Struts2、Spring和iBatis的依赖。例如: ```xml <!-- Struts2 --> <groupId>org.apache.struts <artifactId>struts2-core <version>2.5.17 ...
使用的框架版本是Struts2.0.6、Spring2.5和Hibernate3.2,这些都是当时比较稳定的版本。JDK6.0是Java开发所需的运行环境,MySQL5.0是关系型数据库管理系统。 在开始整合前,我们需要准备数据库。在这个简单的注册...
在本文中,我们将深入探讨如何在Myeclipse环境中配置一个基于Struts2.0.11、Hibernate和Spring的Web项目。这个配置过程分为几个关键步骤,确保所有必要的库和框架能够协同工作。 首先,我们需要在MyEclipse中创建一...
开发环境:本文使用的开发环境是MyEclipse5.0+Eclipse3.2+JDK5.0+Tomcat5.5+Struts2.0.6+Spring2.0.6+Hibernate3.1。 示例:本文的示例是一个图书管理系统,提供了基本的增加、删除、修改、查询等功能。示例使用了...
总之,Spring 3.0.5、Mybatis 3.0.5和Struts2.0.6的整合是一个复杂但重要的过程,它涉及到多个层次的配置和代码编写。理解每个框架的核心功能和它们之间的协作机制,是成功完成整合的关键。通过这样的整合,我们可以...
在与Struts2和JPA的集成中,Spring主要负责管理Bean的生命周期、配置以及处理事务,它提供了无缝的集成解决方案,使得整个应用架构更加清晰、模块化。 #### 综合运用案例分析 在实际开发中,结合Struts2、AJAX、...