webwork+spring+ibatis整合使用

从容器中取值的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 >

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 >

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 >

 

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 >

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 >  


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值