webwork 标签 基本用法 例子

jsp 页面 调用 action

 

<result name="mgtsd1" type="redirect">/market/magercentAction!mgtsd.action</result>

for循环

<ww:bean   id="counter"   name="com.opensymphony.webwork.util.Counter">  
          <ww:param   name="last"   value="10"/>   
          </ww:bean>  
           <ww:iterator   value="#counter">  
               <img src='/pages/smailgame/web/images/yxfl_01_30.gif' width='17' height='13' />
           </ww:iterator>
         

用于action 跳转 action

<ww:property value="contsp.content" escape="true" />

escape="true" 显示html标签是显示还是执行 方法 是true 还是false 自己去试吧

 

<ww:action id="lis" name="netAction!fengqing" namespace="/agritour" executeResult="false"/>

name="netAction!fengqing"     代表引用的action 名字

namespace="/agritour"     代表 action 的相对路径 webwork xml 里

executeResult="false"     如果是 true 那么 相当于 jsp inculde

=========================================

jsp     碟代标签用法

<ww:iterator value="#lis.engpins" status="status">
  
     <td width="130" height="180">
     <table width="109" height="67" border="0" cellpadding="0" cellspacing="0" class="bkang">
                 <tr>
                   <td align="center" valign="middle"><a href="/agritour/agritour/netAction!fengqing.action?idl=<ww:property value="id"/>"><img border="0" id="non_shuoy_18" src="/agritour<ww:property value="image"/>" width="110" height="144" alt="" /></a></td>
                 </tr>
                 <tr>
                 <td height="30" align="center" valign="top">
              
                 <table width="100" height="30" border="0" cellpadding="0" cellspacing="0">
                 <tr>
                   <td width="110" align="center" valign="top" class="STYLE2"><a href="/agritour/agritour/netAction!fengqing.action?idl=<ww:property value="id"/>" ><ww:property value="name"/></a></td>
                 </tr>  
               </table>
            
                 </td>
                 </tr>
               </table>
  
     </td>
     <ww:if test="(#status.index+1)%6==0">
  
     </tr>
     <ww:if test="(#status.index+1)<18">
     <tr>
     </ww:if>
     </ww:if>
     </ww:iterator>

=====================================

 

status="status"     相当于 for 循环     i

============================

如果是 action 挑转   

直接引用 List 名字 无需利用

===========================================

<%@ taglib uri="/WEB-INF/tag/webwork.tld" prefix="ww"%>

标签 的引用

========================================

spring 的 配置文件

***********************************************************************************************

<?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">


<!-- hibernate datasource =================================================================== -->
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
           <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
           <property name="url" value="jdbc:mysql://192.168.1.16:3306/agritour?characterEncoding=GBK"/>
           <property name="username" value="yzhy"/>
           <property name="password" value="yangzhiyong"/>
           <property name="maxActive" value="100"/>
           <property name="maxIdle" value="30"/>
           <property name="maxWait" value="1000"/>
           <property name="defaultAutoCommit" value="true"/>
           <property name="removeAbandoned" value="true"/>
           <property name="removeAbandonedTimeout" value="60"/>
           <property name="logAbandoned" value="true"/>
       </bean>
       <!-- ========================================================================================= -->
    
    
<!-- Hibernate SessionFactory ================================================================ -->
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
           <property name="dataSource" ref="dataSource"/>
           <!-- ====== 指定 Hibernate 映射文件 -->
           <property name="mappingResources">
            <list>
                <value>com/bts/web/agritour/model/Agritour.hbm.xml</value>
                <value>com/bts/web/agritour/model/Toursort.hbm.xml</value>
                <value>
                 com/bts/web/agritour/model/Leavemessage.hbm.xml
                </value></list>
           </property>
           <!-- 配置 Hibernate 属性 -->
           <property name="hibernateProperties">
               <props>
                <!-- 使用 MySQL 方言 -->
                   <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                   <!-- 控制台输出查询语句 -->
                   <!--<prop key="hibernate.show_sql">true</prop>-->
                   <!-- 支持中文查询 -->
                   <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
               </props>
           </property>
       </bean>
       <!-- ========================================================================================= -->
    
    
       <!-- Util beans here ========================================================================= -->
       <bean id="page" class="com.bts.util.Page" scope="prototype">
           <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
       <bean id="template" class="com.bts.util.Template" scope="singleton">
           <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
       <!-- ========================================================================================= -->
    
    
       <!-- 引入前后台的 Spring 配置文件      重点*******

================================================================ -->
<import resource="classes/com/bts/web/agritour/agritour-spring.xml" />
       <!-- ========================================================================================= -->
    
    
</beans>

 

*************************************************************************************

 

webwork xml

 

================================

<!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">
       </package>
    
       <include file="/com/bts/web/agritour/agritour-xwork.xml" />
    
    
</xwork>

================================

配置

地层 webwork xml

******************************************************

<!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">
       </package>
    
       <include file="/com/bts/web/agritour/agritour-xwork.xml" />
    
    
</xwork>

****************************************************************

spring 地层配置

-----------------------------------------------

<?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">

 

<bean id="netAction" class="com.bts.web.agritour.action.NetAction" scope="prototype">
    <property name="page" ref="page"/>
    <property name="template" ref="template"/>
</bean>

</beans>

posted on 2009-10-28 10:31  草原和大树  阅读(5726)  评论(0编辑  收藏  举报