从容器中取值的3种情况:
1,如果上个页面通过model传下来的值,<ww:property value="loginModel.propertyNamexx"/>
2,如果是放到ActionServlet中,则可以<ww:property value="#session['loginModel'].propertyNamexx"/>
3,如果是放到session中,则可以<ww:property value="#loginModel.propertyNamexx"/>
工程目录结构如下:
iterator:标签的使用
<
ww:iterator
id
="oo"
value
="#session['loginModel'].demoList"
status
="index"
>
< ww:if test ="#index.count>=1" >
< p > first: < ww:property value ="#index.first" /></ p >
< p > last: < ww:property value ="#index.last" /></ p >
< p > odd: < ww:property value ="#index.odd" /></ p >
< p > odd: < ww:property value ="#index.even" /></ p >
< p > first: < ww:property value ="#index.index" /></ p >
< p > first: < ww:property value ="#index.count" /></ p >
< ww:if test ="#oo.name=='name'" >
name is 'name'
< ww:if test ="#oo.pass=='name'" >
pass is 'name'
</ ww:if >
</ ww:if >
< ww:else >
< p > name is : < ww:property value ="#oo.name" /></ p >
< p > pass is : < ww:property value ="#oo.pass" /></ p >
</ ww:else >
</ ww:if >
</ ww:iterator >
< ww:if test ="#index.count>=1" >
< p > first: < ww:property value ="#index.first" /></ p >
< p > last: < ww:property value ="#index.last" /></ p >
< p > odd: < ww:property value ="#index.odd" /></ p >
< p > odd: < ww:property value ="#index.even" /></ p >
< p > first: < ww:property value ="#index.index" /></ p >
< p > first: < ww:property value ="#index.count" /></ p >
< ww:if test ="#oo.name=='name'" >
name is 'name'
< ww:if test ="#oo.pass=='name'" >
pass is 'name'
</ ww:if >
</ ww:if >
< ww:else >
< p > name is : < ww:property value ="#oo.name" /></ p >
< p > pass is : < ww:property value ="#oo.pass" /></ p >
</ ww:else >
</ ww:if >
</ ww:iterator >
web.xml配置如下
<?
xml version="1.0" encoding="UTF-8"
?>
< web-app version ="2.4"
xmlns ="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
< display-name > wsi </ display-name >
< context-param >
< param-name > contextConfigLocation </ param-name >
< param-value > /WEB-INF/applicationContext.xml </ param-value >
</ context-param >
<!-- webwork from 2.5 -->
< filter >
< filter-name > webwork </ filter-name >
< filter-class > com.opensymphony.webwork.dispatcher.FilterDispatcher </ filter-class >
</ filter >
< filter-mapping >
< filter-name > webwork </ filter-name >
< url-pattern > /* </ url-pattern >
</ filter-mapping >
<!-- below 2.5 -->
<!-- servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>com.opensymphony.webwork.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.opensymphony.webwork.dispatcher.ServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping -->
<!-- add spring context -->
< listener >
< listener-class > org.springframework.web.context.ContextLoaderListener </ listener-class >
</ listener >
< welcome-file-list >
< welcome-file > index.jsp </ welcome-file >
</ welcome-file-list >
</ web-app >
< web-app version ="2.4"
xmlns ="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
< display-name > wsi </ display-name >
< context-param >
< param-name > contextConfigLocation </ param-name >
< param-value > /WEB-INF/applicationContext.xml </ param-value >
</ context-param >
<!-- webwork from 2.5 -->
< filter >
< filter-name > webwork </ filter-name >
< filter-class > com.opensymphony.webwork.dispatcher.FilterDispatcher </ filter-class >
</ filter >
< filter-mapping >
< filter-name > webwork </ filter-name >
< url-pattern > /* </ url-pattern >
</ filter-mapping >
<!-- below 2.5 -->
<!-- servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>com.opensymphony.webwork.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.opensymphony.webwork.dispatcher.ServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping -->
<!-- add spring context -->
< listener >
< listener-class > org.springframework.web.context.ContextLoaderListener </ listener-class >
</ listener >
< welcome-file-list >
< welcome-file > index.jsp </ welcome-file >
</ welcome-file-list >
</ web-app >
spring的applicationContext放在web-inf下,applicatonContext的配置如下:
<?
xml version="1.0" encoding="UTF-8"
?>
< beans
xmlns ="http://www.springframework.org/schema/beans"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >
<!-- import resource="BeanConfig/xxx.xml"/ -->
<!-- bean id="supplierService" parent="baseTxProxy">
<property name="target">
<bean class="com.pcm.supplier.business.service.SupplierServiceImpl">
<property name="baseDao">
<ref bean="baseDao" />
</property>
</bean>
</property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean -->
< bean id ="demo" class ="com.wsi.action.Demo" init-method ="begin" destroy-method ="close" ></ bean >
< bean id ="sqlMapClient" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
< property name ="configLocation" >
< value > /WEB-INF/SqlMapConfig.xml </ value >
</ property >
</ bean >
< bean id ="dataSource" class ="org.springframework.jndi.JndiObjectFactoryBean" >
< property name ="jndiName" >
< value > jdbc/CrmRs </ value >
</ property >
</ bean >
< bean id ="baseDao" class ="com.pcm.framework.base.orm.BaseDaoImpl" >
< property name ="dataSource" >
< ref bean ="dataSource" />
</ property >
< property name ="sqlMapClient" >
< ref bean ="sqlMapClient" />
</ property >
</ bean >
< bean id ="transactionManager" class ="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
< property name ="dataSource" >
< ref local ="dataSource" />
</ property >
</ bean >
< bean id ="baseTxProxy" lazy-init ="true" class ="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
< property name ="transactionManager" >
< ref local ="transactionManager" />
</ property >
< property name ="transactionAttributes" >
< props >
< prop key ="*" > PROPAGATION_REQUIRED </ prop >
</ props >
</ property >
</ bean >
</ beans >
< beans
xmlns ="http://www.springframework.org/schema/beans"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >
<!-- import resource="BeanConfig/xxx.xml"/ -->
<!-- bean id="supplierService" parent="baseTxProxy">
<property name="target">
<bean class="com.pcm.supplier.business.service.SupplierServiceImpl">
<property name="baseDao">
<ref bean="baseDao" />
</property>
</bean>
</property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean -->
< bean id ="demo" class ="com.wsi.action.Demo" init-method ="begin" destroy-method ="close" ></ bean >
< bean id ="sqlMapClient" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
< property name ="configLocation" >
< value > /WEB-INF/SqlMapConfig.xml </ value >
</ property >
</ bean >
< bean id ="dataSource" class ="org.springframework.jndi.JndiObjectFactoryBean" >
< property name ="jndiName" >
< value > jdbc/CrmRs </ value >
</ property >
</ bean >
< bean id ="baseDao" class ="com.pcm.framework.base.orm.BaseDaoImpl" >
< property name ="dataSource" >
< ref bean ="dataSource" />
</ property >
< property name ="sqlMapClient" >
< ref bean ="sqlMapClient" />
</ property >
</ bean >
< bean id ="transactionManager" class ="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
< property name ="dataSource" >
< ref local ="dataSource" />
</ property >
</ bean >
< bean id ="baseTxProxy" lazy-init ="true" class ="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
< property name ="transactionManager" >
< ref local ="transactionManager" />
</ property >
< property name ="transactionAttributes" >
< props >
< prop key ="*" > PROPAGATION_REQUIRED </ prop >
</ props >
</ property >
</ bean >
</ beans >
xwork配置如下:
<!
DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"
>
< xwork >
< include file ="webwork-default.xml" />
< package name ="default" extends ="webwork-default" >
< default-action-ref name ="home" />
< action name ="index" class ="com.wsi.action.LoginAction" method ="login" >
< result name ="success" > /Succ.jsp </ result >
< result name ="12345" > /Error.jsp </ result >
</ action >
< action name ="doElse" class ="com.wsi.action.LoginAction" method ="doElse" >
< result name ="success" > /Succ.jsp </ result >
< result name ="error" > /Error.jsp </ result >
< result name ="errView" > /er.jsp </ result >
</ action >
</ package >
</ xwork >
< xwork >
< include file ="webwork-default.xml" />
< package name ="default" extends ="webwork-default" >
< default-action-ref name ="home" />
< action name ="index" class ="com.wsi.action.LoginAction" method ="login" >
< result name ="success" > /Succ.jsp </ result >
< result name ="12345" > /Error.jsp </ result >
</ action >
< action name ="doElse" class ="com.wsi.action.LoginAction" method ="doElse" >
< result name ="success" > /Succ.jsp </ result >
< result name ="error" > /Error.jsp </ result >
< result name ="errView" > /er.jsp </ result >
</ action >
</ package >
</ xwork >
ibatis配置文件SqlMapConfig.xml如下:
<?
xml version="1.0" encoding="UTF-8"
?>
<! DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd" >
< sqlMapConfig >
< settings
cacheModelsEnabled ="true"
enhancementEnabled ="true"
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<!-- 映射文件列表 -->
< sqlMap resource ="com/pcm/supplier/access/maps/xxxx.xml" />
</ sqlMapConfig >
<! DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd" >
< sqlMapConfig >
< settings
cacheModelsEnabled ="true"
enhancementEnabled ="true"
lazyLoadingEnabled ="true"
errorTracingEnabled ="true"
maxRequests ="32"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="true"
/>
<!-- 映射文件列表 -->
< sqlMap resource ="com/pcm/supplier/access/maps/xxxx.xml" />
</ sqlMapConfig >