亚洲免费日韩无码系列,亚洲大尺度无码无码专区,中文亚洲成a人片在线观看http://m.tkk7.com/wangbbs2007/category/41702.htmlhttp://m.tkk7.com/wangbbs2007/zh-cnThu, 12 Nov 2009 14:04:39 GMTThu, 12 Nov 2009 14:04:39 GMT60struts2 創建 session request responsehttp://m.tkk7.com/wangbbs2007/articles/301653.html樂vs樂樂vs樂Mon, 09 Nov 2009 01:59:00 GMThttp://m.tkk7.com/wangbbs2007/articles/301653.htmlhttp://m.tkk7.com/wangbbs2007/comments/301653.htmlhttp://m.tkk7.com/wangbbs2007/articles/301653.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/301653.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/301653.html        要獲得上述對象,關鍵Struts 2中com.opensymphony.xwork2.ActionContext類。我們可以通過它的靜態方法getContext()獲取當前Action的上下文對象。有了這個對象我們想獲得其他幾個對象就好辦了

        ActionContext ctx = ActionContext.getContext();     Map session = ctx.getSession();     細心的朋友可以發現這里的session是個map對象在Struts2中底層的session都被封裝成了Map類型我們可以直接操作這個map 進行對session的寫入和讀取操作而不用去直接操作HttpSession對象

        另外,org.apache.struts2.ServletActionContext作為輔助類(Helper Class),可以幫助您快捷地獲得這幾個對象。

        HttpServletRequest request = ServletActionContext.getRequest();     HttpServletResponse response = ServletActionContext.getResponse();     HttpSession session = request.getSession();     如果你只是想訪問session的屬性(Attribute),你也可以通過ActionContext.getContext().getSession()獲取或添加session范圍(Scoped)的對象。



樂vs樂 2009-11-09 09:59 發表評論
]]>
Struts2.0 與Fckeditor上傳文件的問題 http://m.tkk7.com/wangbbs2007/articles/300775.html樂vs樂樂vs樂Mon, 02 Nov 2009 10:50:00 GMThttp://m.tkk7.com/wangbbs2007/articles/300775.htmlhttp://m.tkk7.com/wangbbs2007/comments/300775.htmlhttp://m.tkk7.com/wangbbs2007/articles/300775.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/300775.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/300775.html Security error. You probably don't have enough permissions to upload. Please check your server
還有file upload error num 203
后來才知道和Struts2.0的過濾沖突了
在網絡上查找了下別人是這么說的:
struts2對request進行了封裝,所以當fck的request.getinputStream的時候就會出錯.修改的方法就是對filtermapping的路徑進行修改。

然后對web.XML修改下就可以了
  • <filter>  
  •      <filter-name>struts2</filter-name>    
  •   
  •      <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>    
  •  </filter>  
  •   <filter-mapping>    
  •     <filter-name>struts2</filter-name>    
  •      <url-pattern>*.action</url-pattern>    
  •  </filter-mapping>    
  •        
  •   <filter-mapping>    
  •      <filter-name>struts2</filter-name>    
  •   <url-pattern>*.jsp</url-pattern>    
  • </filter-mapping>    
  •  <welcome-file-list> 


  • 樂vs樂 2009-11-02 18:50 發表評論
    ]]>
    org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.http://m.tkk7.com/wangbbs2007/articles/300044.html樂vs樂樂vs樂Wed, 28 Oct 2009 05:33:00 GMThttp://m.tkk7.com/wangbbs2007/articles/300044.htmlhttp://m.tkk7.com/wangbbs2007/comments/300044.htmlhttp://m.tkk7.com/wangbbs2007/articles/300044.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/300044.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/300044.html     <aop:config>
        <aop:pointcut id="allManagerMethod" expression="execution (* com.test.manager.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
        </aop:config> 

    (expression)路徑出的錯

    出你那個異常是由于expression對應的路徑有問題,請仔細查看,是否為你的程序的包路徑!

    樂vs樂 2009-10-28 13:33 發表評論
    ]]>
    org.hibernate.LazyInitializationException: could not initialize proxy - no Session 18:33:53,484 ERROR LazyInitializationException:42 - could not initialize proxy - no Sessionhttp://m.tkk7.com/wangbbs2007/articles/299959.html樂vs樂樂vs樂Tue, 27 Oct 2009 10:37:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299959.htmlhttp://m.tkk7.com/wangbbs2007/comments/299959.htmlhttp://m.tkk7.com/wangbbs2007/articles/299959.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299959.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299959.html 這個是多對一時沒有家載而關了session后要顯示出現的錯誤

    load改成get  就好使了   
    這是我的解決辦法

    樂vs樂 2009-10-27 18:37 發表評論
    ]]>
    SSH在數據庫中卻查詢不到插入的數據,在查詢分析器中寫insert語句可以插入,并且主鍵會增加1http://m.tkk7.com/wangbbs2007/articles/299955.html樂vs樂樂vs樂Tue, 27 Oct 2009 09:52:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299955.htmlhttp://m.tkk7.com/wangbbs2007/comments/299955.htmlhttp://m.tkk7.com/wangbbs2007/articles/299955.html#Feedback1http://m.tkk7.com/wangbbs2007/comments/commentRss/299955.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299955.html <property name="connection.autocommit">true </property>
    你的數據應該是存在了緩存中,沒有放入數據庫。

    樂vs樂 2009-10-27 17:52 發表評論
    ]]>
    Struts2+spring2.5.x+hibernate3.3.x +ant+xdoclet整合(原創)http://m.tkk7.com/wangbbs2007/articles/299564.html樂vs樂樂vs樂Sat, 24 Oct 2009 05:19:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299564.htmlhttp://m.tkk7.com/wangbbs2007/comments/299564.htmlhttp://m.tkk7.com/wangbbs2007/articles/299564.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299564.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299564.html13:18:45
    1.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">
     
     <!-- struts2 spring 整合 -->
     <listener>
      <listener-class>
       org.springframework.web.context.ContextLoaderListener
      </listener-class>
     </listener>
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
       /WEB-INF/classes/applicationContext-*.xml,classpath*:applicationContext-*.xml
      </param-value>
     </context-param>

     <!--  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      /WEB-INF/classes/applicationContext.xml
      </param-value>
      </context-param>-->
      
      <!-- 自動關閉Hibernatesession -->
     <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>
      <filter-name>Spring character encoding filter</filter-name>
      <filter-class>
       org.springframework.web.filter.CharacterEncodingFilter
      </filter-class>
      <init-param>
       <param-name>encoding</param-name>
       <param-value>GBK</param-value>
      </init-param>
     </filter>
     <filter-mapping>
      <filter-name>Spring character encoding filter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

     <!-- struts2.0配置 -->
     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
     </filter>
     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

     

     <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>
    </web-app>
    2.  struts2-spring-plugin-2.0.14.jar
    3.applicationContext-actions.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <bean id="loginManger" class="com.xushi.Manager.Impl.LoginSericeImpl"/>
    <bean id="login" class="com.xushi.action.LoginAction">
     <property name="loginManger" ref="loginManger"></property>
    </bean>
    </beans>
    4.applicationContext-beans.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    </beans>

    5.applicationContext-common.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <!-- 配置sessionFactory -->
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation">
       <value>classpath:hibernate.cfg.xml</value>
      </property>
     </bean> 
     <!-- 配置事務管理器 --> 
     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory">
       <ref local="sessionFactory"/>
      </property>
     </bean>
       
        <!-- 配置事務特性 -->      
        <tx:advice id="txAdvice" transaction-manager="transactionManager">
         <tx:attributes>
          <tx:method name="add*" propagation="REQUIRED"/>
          <tx:method name="del*" propagation="REQUIRED"/>
          <tx:method name="update*" propagation="REQUIRED"/>
          <tx:method name="*" read-only="true"/>
         </tx:attributes>
        </tx:advice>
       
        <!-- 配置那些類的方法進行事務管理 -->
        <aop:config>
         <aop:pointcut id="allManagerMethod" expression="execution (* com.xushi.manager.*.*(..))"/>
         <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
        </aop:config>         
    </beans>

    6記住配置ant環境變量
    build.xml



    <?xml version="1.0" encoding="GBK"?>
    <project name="OA【01】系統構建腳本" default="生成Hibernate配置文件" basedir=".">

        <property name="src.dir" value="${basedir}/src"/>
     <property name="xdoclet.home" value="D:/xdoclet-plugins-dist-1.0.4"/>

        <!-- Build classpath -->
        <path id="xdoclet.task.classpath">
           <fileset dir="${xdoclet.home}/lib">
              <include name="**/*.jar"/>
           </fileset>
          <!--   <fileset dir="${xdoclet.home}/plugins">
              <include name="**/*.jar"/>
           </fileset>-->
        </path>
     <taskdef 
      name="xdoclet"
      classname="org.xdoclet.ant.XDocletTask"
      classpathref="xdoclet.task.classpath"
     />
     
     <target name="生成Hibernate配置文件">
      <xdoclet>
       <fileset dir="${src.dir}/com/xushi/model">
        <include name="**/*.java"/>
       </fileset>   
       <component
        classname="org.xdoclet.plugin.hibernate.HibernateConfigPlugin"
        destdir="${src.dir}"
        version="3.0"
        hbm2ddlauto="update"
        jdbcurl="jdbc:mysql://localhost/oa"
        jdbcdriver="com.mysql.jdbc.Driver"
        jdbcusername="root"
        jdbcpassword="wzy"
        dialect="org.hibernate.dialect.MySQLDialect"
        showsql="true"
       />
      </xdoclet>
     </target>
     <target name="生成hibernate映射文件">
      <xdoclet>
       <fileset dir="${src.dir}/com/xushi/model">
        <include name="**/*.java"/>
       </fileset>
       <component
        classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
        version="3.0"
        destdir="${src.dir}"
       />
      </xdoclet>
     </target>
    </project>


     7.Orgnization.java

    package com.xushi.model;

    import java.util.Set;

    /**
     *
     * @author Administrator
     * @hibernate.class table="T_Orgnization"
     *
     */
    public class Orgnization {
     
     /**
      * @hibernate.id
      *   generator-class="native"
      */
     private int id;

     /**
      * @hibernate.property
      */
     private String name;
     
     /**
      * @hibernate.property
      */
     private String sn;
     
     /**
      * @hibernate.property
      */
     private String description;
     
     /**
      * @hibernate.many-to-one
      *   column="pid"
      */
     private Orgnization parent;
     
     /**
      * @hibernate.set inverse="true" lazy="extra"
      * @hibernate.key column="pid"
      * @hibernate.one-to-many class="com.xushi.model.Orgnization"
      */
     private Set children;
     
     
     public Set getChildren() {
      return children;
     }
     public void setChildren(Set children) {
      this.children = children;
     }
     public String getDescription() {
      return description;
     }
     public void setDescription(String description) {
      this.description = description;
     }
     public int getId() {
      return id;
     }
     public void setId(int id) {
      this.id = id;
     }
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
     public Orgnization getParent() {
      return parent;
     }
     public void setParent(Orgnization parent) {
      this.parent = parent;
     }
     public String getSn() {
      return sn;
     }
     public void setSn(String sn) {
      this.sn = sn;
     }
    }
    8.Person.java

    package com.xushi.model;

    /**
     *
     * @author Administrator
     * @hibernate.class table="T_Person"
     */
    public class Person {
     
     /**
      * @hibernate.id
      *   generator-class="native"
      */
     private int id;
     
     /**
      * @hibernate.property
      */
     private String name;
     
     /**
      * @hibernate.property
      */
     private String sex;
     
     /**
      * @hibernate.property
      */
     private String address;
     
     /**
      * @hibernate.property
      */
     private String duty;
     
     /**
      * @hibernate.property
      */
     private String phone;
     
     /**
      * @hibernate.property
      */
     private String description;
     
     /**
      * @hibernate.many-to-one
      */
     private Orgnization org;
     
     public String getAddress() {
      return address;
     }
     public void setAddress(String address) {
      this.address = address;
     }
     public String getDescription() {
      return description;
     }
     public void setDescription(String description) {
      this.description = description;
     }
     public String getDuty() {
      return duty;
     }
     public void setDuty(String duty) {
      this.duty = duty;
     }
     public int getId() {
      return id;
     }
     public void setId(int id) {
      this.id = id;
     }
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
     public String getPhone() {
      return phone;
     }
     public void setPhone(String phone) {
      this.phone = phone;
     }
     public String getSex() {
      return sex;
     }
     public void setSex(String sex) {
      this.sex = sex;
     }
     public Orgnization getOrg() {
      return org;
     }
     public void setOrg(Orgnization org) {
      this.org = org;
     }
    }



    樂vs樂 2009-10-24 13:19 發表評論
    ]]>
    Spring Security安全權限管理手冊http://m.tkk7.com/wangbbs2007/articles/299236.html樂vs樂樂vs樂Wed, 21 Oct 2009 11:51:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299236.htmlhttp://m.tkk7.com/wangbbs2007/comments/299236.htmlhttp://m.tkk7.com/wangbbs2007/articles/299236.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299236.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299236.html

    struts2實現 權限管理:http://www.yqdown.com/chengxukaifa/Java/6327.htm   

    樂vs樂 2009-10-21 19:51 發表評論
    ]]>
    IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]http://m.tkk7.com/wangbbs2007/articles/299221.html樂vs樂樂vs樂Wed, 21 Oct 2009 08:49:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299221.htmlhttp://m.tkk7.com/wangbbs2007/comments/299221.htmlhttp://m.tkk7.com/wangbbs2007/articles/299221.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299221.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299221.html加載spring的配置文件時在默認位置/WEB-INF/下找不到applicationContext.xml文件,看了下,myeclipse自動生成的applicationContext.xml放在/WEB-INF/classes下,難怪找不到,終于發現問題了,下面在web.xml中做如下配置即可解決:

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/classes/applicationContext.xml</param-value>  
    </context-param>



    樂vs樂 2009-10-21 16:49 發表評論
    ]]>
    struts2.0 如何獲取action中的值(二) http://m.tkk7.com/wangbbs2007/articles/299141.html樂vs樂樂vs樂Wed, 21 Oct 2009 01:10:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299141.htmlhttp://m.tkk7.com/wangbbs2007/comments/299141.htmlhttp://m.tkk7.com/wangbbs2007/articles/299141.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299141.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299141.html1.index.jsp
           <s:form action="HelloChina.action" method="post">
                Name: <s:textfield name="name" value=""/>
                <s:submit />
            </s:form>
    2.HelloChina

    package com.xushi.bll;

    import java.util.Map;

    import javax.servlet.http.HttpServletRequest;

    import org.apache.struts2.ServletActionContext;

    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;

    public class HelloChina extends ActionSupport {
      private String name;
        
         public String getName() {
             return name;
         }
        
         public void setName(String name) {
             this.name = name;
         }
         public String execute() {
         HttpServletRequest request = ServletActionContext.getRequest();
          request.getSession().setAttribute("abc", request.getParameter("name"));
    //Map map=ActionContext.getContext().getSession();
      //    map.put("abc", request.getParameter("name"));
             return "test";
         }
    }

    3.test.jsp
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        <%@ taglib prefix="s" uri="/struts-tags" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <s:property value="#session.abc" />
    </body>
    </html>

    4.struts.xml
    <action name="HelloChina" class="com.xushi.bll.HelloChina">
       <result name="test">/pack/test.jsp</result>  
      </action>



    樂vs樂 2009-10-21 09:10 發表評論
    ]]>
    struts2.0 如何獲取action中的值(一)http://m.tkk7.com/wangbbs2007/articles/299138.html樂vs樂樂vs樂Wed, 21 Oct 2009 00:59:00 GMThttp://m.tkk7.com/wangbbs2007/articles/299138.htmlhttp://m.tkk7.com/wangbbs2007/comments/299138.htmlhttp://m.tkk7.com/wangbbs2007/articles/299138.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/299138.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/299138.html        <s:form action="HelloChina.action" method="post">
                Name: <s:textfield name="name" value=""/>
                <s:submit />
            </s:form>
    2.HelloChina

    package com.xushi.bll;

    import java.util.Map;

    import javax.servlet.http.HttpServletRequest;

    import org.apache.struts2.ServletActionContext;

    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;

    public class HelloChina extends ActionSupport {
      private String name;
        
         public String getName() {
             return name;
         }
        
         public void setName(String name) {
             this.name = name;
         }
         public String execute() {
             return "test";
         }
    }

    3.test.jsp
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
        <%@ taglib prefix="s" uri="/struts-tags" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <s:textfield value="${requestScope.name}"></s:textfield>
    <s:property value="name"/>
    </body>
    </html>

    4.struts.xml
    <action name="HelloChina" class="com.xushi.bll.HelloChina">
       <result name="test">/pack/test.jsp</result>  
      </action>



    樂vs樂 2009-10-21 08:59 發表評論
    ]]>
    s:iteratorhttp://m.tkk7.com/wangbbs2007/articles/298431.html樂vs樂樂vs樂Thu, 15 Oct 2009 10:35:00 GMThttp://m.tkk7.com/wangbbs2007/articles/298431.htmlhttp://m.tkk7.com/wangbbs2007/comments/298431.htmlhttp://m.tkk7.com/wangbbs2007/articles/298431.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/298431.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/298431.html     List li = new ArrayList();
        for(int i=0;i <5;i++){
        List l = new ArrayList();
        l.add(i+"1");
        l.add(i+"2");
        li.add(l);
        }
        request.setAttribute("list",li);
      %>
      <p>迭代測試222222222222222 </p>
      <s:iterator value="#request.list" id="list1">
          <s:iterator value="#list1" >
              <s:property />
          </s:iterator>
      </s:iterator>

    樂vs樂 2009-10-15 18:35 發表評論
    ]]>
    struts2 標簽 實現 for循環http://m.tkk7.com/wangbbs2007/articles/298264.html樂vs樂樂vs樂Wed, 14 Oct 2009 09:46:00 GMThttp://m.tkk7.com/wangbbs2007/articles/298264.htmlhttp://m.tkk7.com/wangbbs2007/comments/298264.htmlhttp://m.tkk7.com/wangbbs2007/articles/298264.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/298264.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/298264.html 第<s:property value="currentPage"/>頁
    共<s:property value="totalPages"/>頁

    <s:bean name="org.apache.struts2.util.Counter" id="counter">
       <s:param name="first" value="1" />
       <s:param name="last" value="#fot.totalPages" />
       <s:iterator>
         counter:<s:property/>
          <option value="<s:property/>" <s:property value="currentPage"/> >第<s:property/>頁</option>
       </s:iterator>
    </s:bean>

     </s:iterator>

    樂vs樂 2009-10-14 17:46 發表評論
    ]]>
    struts2 note 攔截器http://m.tkk7.com/wangbbs2007/articles/298109.html樂vs樂樂vs樂Tue, 13 Oct 2009 13:09:00 GMThttp://m.tkk7.com/wangbbs2007/articles/298109.htmlhttp://m.tkk7.com/wangbbs2007/comments/298109.htmlhttp://m.tkk7.com/wangbbs2007/articles/298109.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/298109.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/298109.html 要手動添加默認的攔截器
    <interceptor-ref name="defaultStack"/>

    樂vs樂 2009-10-13 21:09 發表評論
    ]]>
    STRUTS2.0 常用標簽使用http://m.tkk7.com/wangbbs2007/articles/298029.html樂vs樂樂vs樂Tue, 13 Oct 2009 02:20:00 GMThttp://m.tkk7.com/wangbbs2007/articles/298029.htmlhttp://m.tkk7.com/wangbbs2007/comments/298029.htmlhttp://m.tkk7.com/wangbbs2007/articles/298029.html#Feedback2http://m.tkk7.com/wangbbs2007/comments/commentRss/298029.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/298029.html1. Struts2頁面開發中常用標簽使用說明
    1.1.往action里傳值的使用方式:
    <input name="userName" type="text" class="input6" size="15">
    a. userName屬性需要在訪問的action中提供相應的屬性,并有SET/GET方法。
    b. 可以不在訪問的action中提供相應的屬性,用request.getParameter(“userName”);

    1.2.顯示標簽 property 用于輸出指定值:
    <s:property value=" userName "/> 當action返回到指定頁面是,可以通過該標簽顯示action中的屬性

    信息。(注 userName必須在action中存在,并有GET方法)。

    1.3.往對象中傳值<s:textfield> 用于從頁面往action中的對象內傳值:
    <s:text name="user. userName " id="username"/>
    該標簽可以在頁面中向action中的實體對象內直接傳值。(注:在action中要存在user對象,并有

    SET/GET方法。)

    1.4.判斷<s:if> </s:if> 用于在頁面中判斷指定數據
    <s:if test="userName == admin">…. </s:if>
    <s:else>…. </s:else>
    該標簽用于對指定的數據進行判斷,但指定的數據必須在action中存在。

    1.5.迭代<s:iterator>用于將List、Map、ArrayList等集合進行循環遍歷
    <s:iterator value="userList" id="user" status="u">
    <s:property value="userName"/></a>
    </s:iterator>
    該標簽用于將userList集合中的元素進行循環,用過property進行顯示集合中的指定元素值。

    1.6.URL地址標簽,<s:url>用于生成一個URL地址,可以通過URL標簽指定的<s:param>子元素向URL地址

    發送請求參數
    <s:url action=" ">
               <s:param name=" " value=""></s:param>
           </s:url>
    其中action為請求地址,param子元素為地址后面所帶的參數。

    1.7.超鏈接 <a href >一般和<s:url>標簽一起使用,用于帶多個參數。
           <s:url id='url' action='HelloWorld'>
               <s:param name="request_locale">en</s:param>
          </s:url>
           <s:a href="%{url}">超鏈接</s:a>

    1.8.set標簽,用于將某個值放入指定的范圍內。例如application,session等。
    <s:set name="user" value="userName" scope=”request”/>
    將user值放入request范圍內。

    2. Struts2頁面開發中常用標簽使用規范:
    1.1.通過<input name="userName" type="text" class=" " size="15">
    往action中傳值,action中要有相應的屬性,并提供SET/GET方法。
    (在數量少時可以使用request.getParameter(“userName”);)

    1.2.在頁面顯示action傳來的數據,使用property標簽。需要顯示的數據從action中獲得。

    1.3.往action中的實體對象內傳值,使用textfield標簽。

    1.4.在頁面中判斷指定值使用<s:if>標簽。判斷數據從action中獲得。

    1.5.在頁面中需要循環列表顯示的數據使用<s:iterator>標簽,列表數據從action中獲得。

    1.6.URL地址和超鏈接可以使用<a href>和<s:url>,在傳多值時建議<a href>和<s:url>一起使用

     

    按字母分類:

    A:
    <s:a xhref=""></s:a>-----超鏈接,類似于html里的<a></a>
    <s:action name=""></s:action>-----執行一個view里面的一個action
    <s:actionerror/>-----如果action的errors有值那么顯示出來
    <s:actionmessage/>-----如果action的message有值那么顯示出來
    <s:append></s:append>-----添加一個值到list,類似于list.add();
    <s:autocompleter></s:autocompleter>-----自動完成<s:combobox>標簽的內容,這個是ajax

    B:
    <s:bean name=""></s:bean>-----類似于struts1.x中的,JavaBean的值

    C:
    <s:checkbox></s:checkbox>-----復選框
    <s:checkboxlist list=""></s:checkboxlist>-----多選框
    <s:combobox list=""></s:combobox>-----下拉框
    <s:component></s:component>-----圖像符號

    D:
    <s:date/>-----獲取日期格式
    <s:datetimepicker></s:datetimepicker>-----日期輸入框
    <s:debug></s:debug>-----顯示錯誤信息
    <s:div></s:div>-----表示一個塊,類似于html的<div></div>
    <s:doubleselect list="" doubleName="" doubleList=""></s:doubleselect>-----雙下拉框

    E:
    <s:if test=""></s:if>
    <s:elseif test=""></s:elseif>
    <s:else></s:else>-----這3個標簽一起使用,表示條件判斷

    F:
    <s:fielderror></s:fielderror>-----顯示文件錯誤信息
    <s:file></s:file>-----文件上傳
    <s:form action=""></s:form>-----獲取相應form的值

    G:
    <s:generator separator="" val=""></s:generator>----和<s:iterator>標簽一起使用

    H:
    <s:head/>-----在<head></head>里使用,表示頭文件結束
    <s:hidden></s:hidden>-----隱藏值

    I:
    <s:i18n name=""></s:i18n>-----加載資源包到值堆棧
    <s:include value=""></s:include>-----包含一個輸出,servlet或jsp頁面
    <s:inputtransferselect list=""></s:inputtransferselect>-----獲取form的一個輸入
    <s:iterator></s:iterator>-----用于遍歷集合

    L:
    <s:label></s:label>-----只讀的標簽

    M:
    <s:merge></s:merge>-----合并遍歷集合出來的值

    O:
    <s:optgroup></s:optgroup>-----獲取標簽組
    <s:optiontransferselect doubleList="" list="" doubleName=""></s:optiontransferselect>-----左右選擇框

    P:
    <s:param></s:param>-----為其他標簽提供參數
    <s:password></s:password>-----密碼輸入框
    <s:property/>-----得到'value'的屬性
    <s:push value=""></s:push>-----value的值push到棧中,從而使property標簽的能夠獲取value的屬性

    R:
    <s:radio list=""></s:radio>-----單選按鈕
    <s:reset></s:reset>-----重置按鈕

    S:
    <s:select list=""></s:select>-----單選框
    <s:set name=""></s:set>-----賦予變量一個特定范圍內的值
    <s:sort comparator=""></s:sort>-----通過屬性給list分類
    <s:submit></s:submit>-----提交按鈕
    <s:subset></s:subset>-----為遍歷集合輸出子集

    T:



    樂vs樂 2009-10-13 10:20 發表評論
    ]]>
    jsp超鏈接 用 struts2 標簽傳多個參數 以及解決最后一個字亂碼問題http://m.tkk7.com/wangbbs2007/articles/298028.html樂vs樂樂vs樂Tue, 13 Oct 2009 02:16:00 GMThttp://m.tkk7.com/wangbbs2007/articles/298028.htmlhttp://m.tkk7.com/wangbbs2007/comments/298028.htmlhttp://m.tkk7.com/wangbbs2007/articles/298028.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/298028.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/298028.html              <s:url action='Ypbf.action'>
                        <s:param name='title'><s:property value="title"/></s:param>
                        <s:param name='speciality'><s:property value="speciality"/></s:param>
                </s:url>
              ">
         <s:property value="title"/>
         </a>

    樂vs樂 2009-10-13 10:16 發表評論
    ]]>
    Struts2.0頁面跳轉css無效問題的解決方法http://m.tkk7.com/wangbbs2007/articles/297877.html樂vs樂樂vs樂Mon, 12 Oct 2009 05:02:00 GMThttp://m.tkk7.com/wangbbs2007/articles/297877.htmlhttp://m.tkk7.com/wangbbs2007/comments/297877.htmlhttp://m.tkk7.com/wangbbs2007/articles/297877.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/297877.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/297877.html閱讀全文

    樂vs樂 2009-10-12 13:02 發表評論
    ]]>
    <s:property value="content" escape="false"/> 放到input中不好使http://m.tkk7.com/wangbbs2007/articles/297876.html樂vs樂樂vs樂Mon, 12 Oct 2009 04:11:00 GMThttp://m.tkk7.com/wangbbs2007/articles/297876.htmlhttp://m.tkk7.com/wangbbs2007/comments/297876.htmlhttp://m.tkk7.com/wangbbs2007/articles/297876.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/297876.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/297876.html
    注意引號(單引號)

    樂vs樂 2009-10-12 12:11 發表評論
    ]]>
    strust2標簽實踐總結http://m.tkk7.com/wangbbs2007/articles/297847.html樂vs樂樂vs樂Mon, 12 Oct 2009 01:37:00 GMThttp://m.tkk7.com/wangbbs2007/articles/297847.htmlhttp://m.tkk7.com/wangbbs2007/comments/297847.htmlhttp://m.tkk7.com/wangbbs2007/articles/297847.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/297847.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/297847.html 2:在頁面中實現自動增加的序號用iterator的statuts的index屬性 eg:
    <s:iterator value="#request.inOutAccountList" id="data" status="listStat">
    <s:property value="#listStat.index+1"/>
    <!—輸出當前迭代元素的索引?
    <s:property value="#listStat.index"/>
    <!—輸出當前迭代了幾個元素?
    <s:property value="#listStat.count"/>
    <!—返回當前迭代元素的索引是否為奇數?
    <s:property value="#listStat.odd"/>
    <!—返回當前迭代元素的索引是否為偶數?
    <s:property value="#listStat.event"/>
    <!—返回當前元素是否為第一個元素?
    <s:property value="#listStat.first"/>
    <!—返回當前元素是否為最后一個元素?
    <s:property value="#listStat.last"/>
    </s:iterator>
    3:在action類中取得request和session對象的方法
    Map session  = ActionContext.getContext().getSession();
    HttpServletRequest  request = ServletActionContext.getRequest ();
    設置它們的值的方法:
    session.put("operation", "add");
    request.setAttribute("name", name);
    頁面中取得它們的值:
    <s:property value="#session.operation"/>
    <s:property value="#session[‘operation’]"/>
    ${sessionScope.TEST} == ${session.TEST}
    <s:if test="#session.operation =='add'">
    <s:if test="#session[‘operation’]=='add'">
    <s:if test="#session[‘operation’]==null">

    <s:property value="#request.name"/>
    ${requestScope.name} == ${request.name}
    4:頁面中奇偶行樣式不一樣的控制方法:
    <tr class="<s:if test='#listStat.odd==true'>tableStyle-tr1</s:if><s:else>tableStyle-tr2</s:else>" >
    5:單選框和復選框的使用方法
    1):可以設置默認選中值,注意list的值的設置,通過這種方式使key和value不一樣,這種方法比較常用(checkboxlist or radio)
    <s:radio name="uncarInsPolicy.policyStateCode"
    list="#{'5':'通過' , '2':'不通過'}" listKey="key" listValue="value" value='5' />
    2):這里的key和value的值是一樣的(checkboxlist or radio)
    <s:checkboxlist list="{'Red', 'Blue', 'Green'}" name="favoriteColor"/>
    6:struts2 中的標簽會生成類似由<tr><td></td></tr>構成的字串(具體什么標簽生成什么,可以查 看生成后的頁面的源代碼)如果不限制這些多余代碼的生成,頁面將變得無法控制,所以一般我們是不希望它生成多余的代碼的,具體的設置方法如果,在 struts.xml中統一配置
    <constant name="struts.ui.theme" value="simple"/>加上該句即可
    也可以通過在頁面中將tag的theme屬性設為"simple"取消其默認的表格布局
    不過最好是:自定義一個theme,并將其設為默認應用到整個站點,如此一來就可以得到統一的站點風格
    7:jsp頁面中格式化日期的方法
    <s:date name="unCarInsModificationInfo.createTime" format="yyyy-MM-dd" nice="false"/>這樣就可以將日期格式化為yyyy-MM-dd的形式
    8:默認情況下,當請求action發生時,Struts運行時(Runtime)根據struts.xml里的Action映射集(Mapping),實例化action對應的類,并調用其execute方法。當然,我們可以通過以下兩種方法改變這種默認調用
    1)在classes/sturts.xml中新建Action,并指明其調用的方法
    比如想調用action類中的
    public String aliasAction() {
        message ="自定義Action調用方法";
        return SUCCESS;
    }
    則在classes/sturts.xml中加入下面代碼:
    <action name="AliasHelloWorld" class="tutorial.HelloWorld"method="aliasAction">
       <result>/HelloWorld.jsp</result>
    </action>
    既可用action名調用該方法了
    2)(比較常用)
    訪問Action時,在Action名后加上“!xxx”(xxx為方法名)。
    9:Struts 2.0有兩個配置文件,struts.xml和struts.properties都是放在WEB-INF/classes/下。
    struts.xml用于應用程序相關的配置
    struts.properties用于Struts 2.0的運行時(Runtime)的配置
    10:在action類中取得web下某一文件夾物理路徑(絕對路徑)的方法
    filePath = ServletActionContext.getServletContext().getRealPath("/upLoadFiles")
    11:要想返回的頁面不是一個直接JSP頁面而是要先通過返回action中的方法讀取相應的數據再返回到jsp頁面,有兩種方法
    1)在struts.xml中這么設置
    <result name="list" type="redirect-action">sysmanage/UserBaseInfoAction!findUserBaseInfo.action</result>
    2)在action中返回時直接調用這個方法即可
    return findList();
    12:設置checkboxlist中默認值的方法
    <s:checkboxlist name="skills1"="Skills 1" list="{ 'Java', '.Net', 'RoR', 'PHP' }" value="{ 'Java', '.Net' }" />
    <s:checkboxlist name="skills2"
        label="Skills 2" list="#{ 1:'Java', 2: '.Net', 3: 'RoR', 4: 'PHP' }" listKey="key" listValue="value" value="{ 1, 2, 3 }"/>
    13:二級級連下拉框
    <s:set name="foobar"
       value="#{'Java': {'Spring', 'Hibernate', 'Struts 2'}, '.Net': {'Linq', ' ASP.NET 2.0'}, 'Database': {'Oracle', 'SQL Server', 'DB2', 'MySQL'}}" />
    <s:doubleselect list="#foobar.keySet()" doubleName="technology" doubleList="#foobar[top]" label="Technology" />
    14:在頁面中取出list對象中的屬性值
    <s:if test="list!=null&&list.size()>0">
    <s:iterator value="list" status=”stat”>
    <!—如果list中存儲形式為select id,name,title-- >
    <s:property value="list[#stat.index][0]" />
    <!—如果list中存儲多對象如left join Role left join Group-- >
    <s:property value="list[#stat.index][0].title" />
    <s:property value="list[#stat.index][1].title" />
    <!—如果為Map形式存儲-- >
    <s:iterator value="mapUsers.keySet()" id="id">
       <s:property value="#id"/>
       <s:iterator value="mapUsers.get(#id)">
       <s:property value="nickname"/>||<s:property value="UName"/>
       </s:iterator>
    </s:iterator>
    <!—判斷是否為奇數-- >
    <s:if test="stat.odd == true"></s:if>
    <!—判斷是否為第一條數據-- >
    <s:if test="#stat.index==0">
    <s:if test="#stat.first">
    <!—判斷屬性是否為null-- >
    <s:if test="list[#stat.index][0].title ==null”>
    <!—將屬性值聲明為變量-- >
    <s:set name="title" value="list[#stat.index][0].title " ></s:set>
    <!—判斷屬性值-- >
    <s:if test="list[#stat.index][0].title ==4">
    <s:if test="list[#stat.index][0].title ==’admin’">
    <s:if test="#title ==4">
    <s:if test="list[#stat.index][0].title.length()>15">
    <s:property value="list[#stat.index][0].title.substring(0,15)" />...
    </s:if>


    14:獲取select值
    <s:select list="listDept" name="selectDept" listKey="val" listValue="prntext" disabled = "true" value="deptSelected" />

    <s:hidden name="selectDept" value="%{deptSelected}"/>

    15:循環指定int型數據
    其中first屬性指定循環起始值,last指定循環終止值,其它相關屬性可以查看org.apache.struts2.util.Counter類源碼。在下面迭代器中輸入循環的當前值,即:current
    <s:bean name="org.apache.struts2.util.Counter">
    <s:param name="first" value="1" />
    <s:param name="last" value="pages" /><!—pages page為action中屬性?
    <s:iterator>
    <s:if test="current-1==page">
    <font color="red"><s:property /></font>
    </s:if>
    <s:else>
    [<s:property />]
    </s:else>
    </s:iterator>
    </s:bean>

    16:輸出國際化文件中的值
    <s:text name=”key”>
    ${getText[“key”]}
    17:輸出Action中的消息
    <s:actionmessage />
    18:輸出Action中的錯誤
    <s:actionerror />


    樂vs樂 2009-10-12 09:37 發表評論
    ]]>
    struts2.0亂碼 在struts.xml里面設置struts.i18n.encoding=utf-8依然出現亂碼是怎么回事呀http://m.tkk7.com/wangbbs2007/articles/297804.html樂vs樂樂vs樂Sun, 11 Oct 2009 11:20:00 GMThttp://m.tkk7.com/wangbbs2007/articles/297804.htmlhttp://m.tkk7.com/wangbbs2007/comments/297804.htmlhttp://m.tkk7.com/wangbbs2007/articles/297804.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/297804.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/297804.html 是 get  還是 post 傳參

    1. 第四個可能性就是在web.xml中需要設置一個Filter ,將編碼設置成utf-8
       <!-- STRUTS2 utf-8 -->
     <filter>
            <filter-name>struts-cleanup</filter-name>
            <filter-class>
                org.apache.struts2.dispatcher.ActionContextCleanUp
            </filter-class>       
        </filter>
       
        <filter-mapping>
            <filter-name>struts-cleanup</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

    2. 第一個可能性是顯示的jsp里面的content-type要設置對.
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    3. 第二個就是jsp文件的編碼需要是ASCII編碼形式

    4. 第三個就是應用服務器的版本, 如果是tomcat 的話,5.5版本后需要在每個頁面都設置
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    在server.xml中
    <Connector port="8080"

    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"

    enableLookups="false" redirectPort="8443" acceptCount="100"

    debug="0" connectionTimeout="20000" useBodyEncodingForURI="true"

    disableUploadTimeout="true" URIEncoding=”UTF-8”/>


    加上就可以.

    如果還有問題可能就是數據庫的問題.
    數據庫的連接字符串需要設置對.

    樂vs樂 2009-10-11 19:20 發表評論
    ]]>
    Struts 2 struts.xml http://m.tkk7.com/wangbbs2007/articles/297802.html樂vs樂樂vs樂Sun, 11 Oct 2009 10:39:00 GMThttp://m.tkk7.com/wangbbs2007/articles/297802.htmlhttp://m.tkk7.com/wangbbs2007/comments/297802.htmlhttp://m.tkk7.com/wangbbs2007/articles/297802.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/297802.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/297802.html<?xml version="1.0" encoding="GBK" ?>
    <!--指定struts2配置文件的DTD信息-->
    <!DOCTYPE struts PUBLIC
     "-//apache Software Foundation//DTD Struts Configuation 2.0//EN"
     "http://struts.apache.org/dtds/struts-2.0.dtd">
    <!-- struts 是struts2配置文件的根元素-->
    <struts>
        <!--設置Struts 2應用是否使用開發模式--> 
     <constant name="struts.devMode" value="true"></constant>
     <!--每次Http請求到達時,是否重新加載資源文件-->
     <constant name="struts.i18n.reload" value="true"></constant>
     <!--struts.xml文件系統改變后,系統是否重新加載該文件-->
     <constant name="struts.configuration.xml.reload" value="true"></constant>
     <!--指定web應用的默認編碼集-->
     <constant name="struts.i18n.encoding" value="gb2312"></constant>
     <!--指定所需的國際化資源-->
     <constant name="struts.custom.i18n.resources" value="messageResource"></constant>
     <!--指定需要Struts 2處理請求的后綴-->
     <constant name="struts.action.extension" value="jspa" />
     <!--struts2的Action必須放在指定的包空間下定義-->
     <package name="strutsqs" extends="struts-default">  
      <global-results>
       <!-- 當返回login視圖名時,轉入/login/login.jsp頁面登錄 -->   
       <result name="common_error">/deal/error.jsp</result>
      </global-results>  
     </package> 
     <include file="struts-user.xml"></include>
    </struts>

    樂vs樂 2009-10-11 18:39 發表評論
    ]]>
    Struts2,Spring,Hibernate整合例子一個http://m.tkk7.com/wangbbs2007/articles/295326.html樂vs樂樂vs樂Wed, 16 Sep 2009 07:50:00 GMThttp://m.tkk7.com/wangbbs2007/articles/295326.htmlhttp://m.tkk7.com/wangbbs2007/comments/295326.htmlhttp://m.tkk7.com/wangbbs2007/articles/295326.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/295326.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/295326.html項目目錄:



     

    User.java

    package com.zx.test.model;

    public class User {

     private Long id;
     
     private String name;
     
     private Integer age;
     
     private String password;

       //   get/set方法
     
    }

    User.hbm.xml

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "

    <hibernate-mapping>
        <class name="com.zx.test.model.User" table="LB_USER">
            <id name="id" type="java.lang.Long">
                <column name="ID"/>
                <generator class="sequence">
                  <param name="sequence">SEQ_LB_USER</param>
                </generator>
            </id>
            <property name="name" type="java.lang.String">
                <column name="name" length="20"/>
            </property>
            <property name="age" type="java.lang.Integer">
                <column name="age" length="2"/>
            </property>
            <property name="password" type="java.lang.String">
                <column name="password" length="20"/>
            </property>
        
        </class>
    </hibernate-mapping>

    UserDao.java

    package com.zx.test.dao;

    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

    import com.zx.test.model.User;

    public class UserDao extends HibernateDaoSupport {
     
     /**
      * 保存user
      * @param user
      */
     public void saveUser(User user){
    //  spring自帶方法 保存
      this.getHibernateTemplate().save(user);
     }

    //update, delete ,findAll 方法同上,省略!

    }

     

    UserService.java

    package com.zx.test.service;

    import com.zx.test.dao.UserDao;
    import com.zx.test.model.User;

    public class UserService {

     private UserDao userDao;
     
     public void setUserDao(UserDao userDao) {
      this.userDao = userDao;
     }


     public void saveUser(User user){
      userDao.saveUser(user);
     }

    // 在此處添加業務邏輯方法;
    }

    UserAction.java

     

    package com.zx.test.action;

    import com.opensymphony.xwork2.ActionSupport;
    import com.zx.test.model.User;
    import com.zx.test.service.UserService;

    public class UserAction extends ActionSupport {

     private User user;
      
     public User getUser() {
      return user;
     }

     public void setUser(User user) {
      this.user = user;
     }
     
     
     private UserService userService ;

     public void setUserService(UserService userService) {
      this.userService = userService;
     }
     
     
     public String userAdd(){
      
      this.userService.saveUser(user);
      
      return SUCCESS;
     }

    //添加action方法

    }

    struts.xml:

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "
       
    <struts>
      <include file="struts-default.xml"/>
      <package name="user" extends="struts-default" namespace="/user">
        <action name="userAdd" class="userAction" method="userAdd">
           <result name="success">/userShow.jsp</result>
        </action>
      </package>
    </struts>

    hibernate.cfg.xml

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "
    <hibernate-configuration>
    <session-factory>
     <!-- 基本配置 -->
     <property name="dialect">
      org.hibernate.dialect.Oracle9Dialect
     </property>
     <property name="show_sql">false</property>
     <property name="format_sql">true</property>
     <property name="bytecode.use_reflection_optimizer">true</property>
     <property name="max_fetch_depth">2</property>
     <property name="default_batch_fetch_size">8</property>
     <property name="jdbc.batch_size">20</property>
     
     
     <mapping resource="com/zx/test/model/User.hbm.xml" />

    </session-factory>
    </hibernate-configuration>

     

    applicationContext.xml


       
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value ="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value ="jdbc:oracle:thin:@192.168.0.95:1521:ZXDB2"/>
        <property name="username" value ="test"/>
        <property name="password" value ="test"/>
       
       </bean>
       
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
         <ref local="dataSource"/>
        </property>
        <property name="configLocation">
         <value type="org.springframework.core.io.Resource">classpath:hibernate.cfg.xml</value>
        </property>
       </bean>
       
       <bean id="userDao" class="com.zx.test.dao.UserDao">
         <property name="sessionFactory" ref="sessionFactory"></property>
       </bean>
       
       <bean id="userService" class="com.zx.test.service.UserService">
         <property name="userDao" ref="userDao"></property>
       </bean>
       
       <bean id="userAction" class="com.zx.test.action.UserAction" scope="prototype">
         <property name="userService" ref="userService"></property>
       </bean>

     

    web.xml:

    <!-- 配置Struts2 -->
      <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
     </filter>
     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     <!--  配置Spring  -->
     <listener>
      <listener-class>
       org.springframework.web.context.ContextLoaderListener  </listener-class>
     </listener>
     
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:*.xml</param-value>
     </context-param>

    index.jsp:

    <form action="<%=request.getContextPath() %>/user/userAdd.action" name="form1" method="post">
       
           userName: <input type ="text" name="user.name"><br>
           password:<input type="password" name="user.password"><br>
           age:<input type="text" name="user.age"><br>
           <input type="submit" value="submit">&nbsp;<input type="reset" value="reset">
        </form>

    userShow.jsp

    在第一行添加 struts2 的標簽

    即:<%@ taglib prefix="s" uri="/struts-tags" %>

    <body>
     
           userName: <s:property value="user.name"/><br>
           password:<s:property value="user.password"/><br>
           age:<s:property value="user.age"/>
       
      </body>

     


    struts.properties 文件可要可無!(可以自己配置)



    樂vs樂 2009-09-16 15:50 發表評論
    ]]>
    struts2.0 hibernate spring 整合步驟http://m.tkk7.com/wangbbs2007/articles/295324.html樂vs樂樂vs樂Wed, 16 Sep 2009 07:46:00 GMThttp://m.tkk7.com/wangbbs2007/articles/295324.htmlhttp://m.tkk7.com/wangbbs2007/comments/295324.htmlhttp://m.tkk7.com/wangbbs2007/articles/295324.html#Feedback0http://m.tkk7.com/wangbbs2007/comments/commentRss/295324.htmlhttp://m.tkk7.com/wangbbs2007/services/trackbacks/295324.html1.建立web項目
    2.在web.xml  配置 struts2,和 spring ,
     <!-- 配置Struts2 -->
      <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher(struts的過濾器)
      </filter-class>
     </filter>
     <filter-mapping>(加載struts2)
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     <!--  配置Spring  -->
     <listener>
      <listener-class>
       org.springframework.web.context.ContextLoaderListener(spring監聽器)
      </listener-class>
     </listener>
     <!--  查找spring配置文件 -->
     <context-param>(程序從此處開始加載.xml 文件,并執行)
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:*.xml</param-value>
     </context-param>
    3.在src根目錄下創建struts.xml文件
      <include file="struts-default.xml"/>固定格式,用到此包
    4.在src根目錄 創建hibernate.cfg.xml文件
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            " <hibernate-configuration>
    <session-factory>
     <!-- 基本配置 -->
     <property name="dialect">
      org.hibernate.dialect.Oracle9Dialect
     </property>
     <property name="show_sql">false</property>
     <property name="format_sql">true</property>
     <property name="bytecode.use_reflection_optimizer">true</property>
     <property name="max_fetch_depth">2</property>
     <property name="default_batch_fetch_size">8</property>
     <property name="jdbc.batch_size">20</property>

    </session-factory>
    </hibernate-configuration>
    系統給的文件 只需要拷貝,都是一些數據庫庫的基本配置

    5.在src根目錄 拷貝struts.properties文件

    struts.objectFactory = spring   該項是告訴系統 用spring來 控制hibernate和Action
    struts.action.extension=action  告訴系統訪問時以什么結尾。可以改為:  do  例如:login.do   ,此處為:login.action
    6.在src根目錄下 創建applicationContext.xml
     配置數據源
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value ="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value ="jdbc:oracle:thin:@192.168.0.95:1521:ZXDB2"/>
        <property name="username" value ="test"/>
        <property name="password" value ="test"/>
       
       </bean>

     創建sessionFactory 工廠
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
         <ref local="dataSource"/>
        </property>
        <property name="configLocation">
         <value type="org.springframework.core.io.Resource">classpath:hibernate.cfg.xml</value>
        </property>
       </bean>
     考來用

    7.創建 實體類
     就是寫一個bean 含有get/set 方法
    8.在實體類所在的目錄下,寫一個 類名.hbm.xml文件,在配置文件中添加屬性
     <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
      "

      <hibernate-mapping>
          <class name="com.zx.test.model.User" table="LB_USER">
       <id name="id" type="java.lang.Long">主鍵的類型為Long
           <column name="ID"/>
           <generator class="sequence">
             <param name="sequence">SEQ_LB_USER</param>指定主鍵生成方式,必須在pl/sql創建主鍵生成方式
           </generator>
       </id>
       <property name="name" type="java.lang.String">
           <column name="name" length="20"/>
       </property>
       <property name="age" type="java.lang.Integer">
           <column name="age" length="2"/>
       </property>
       <property name="password" type="java.lang.String">
           <column name="password" length="20"/>
       </property>
       所有屬性的name 必須與 bean中的set后的名稱一樣
          
          </class>
      </hibernate-mapping>

    9.創建一個 Dao 實現操作方法
     
    10 創建 service  調用  Dao中的方法
     
    11.創建  Action   將service的得到的user 加到Action中

     
    12.在applicationContext.xml 中配置
     將userDao注入到sessionFactory中
     將userService 注入到UserDao中
     將userAction 注入到 userService中
    13.在struts.xml中 配置Action
       <package name="user" extends="struts-default(固定與include對應)" namespace="/use(訪問時路徑)r">
        <action name="userAdd(訪問時路徑)" class="userAction" method="userAdd">
           <result name="success">/userShow.jsp</result>
        </action>
      </package>

     此處配置了訪問時的路徑:/user/userAdd

    14.將8中的配置文件 加入到 4 中
     <mapping resource="com/zx/test/model/User.hbm.xml" />
     引用配置文件

    15.寫jsp頁面 表單提交到 Action

    9.10.11:是 Action 調用 Service ,Service調用 Dao 也是分層的體現

     

    Web.xml 是web工程的配置文件

    ApplicationContext  是 spring的配置文件

    Hibernate.hbm.xml 是hibernate的配置文件


    建表是 注意創建主鍵時 name 為 表明

     



    樂vs樂 2009-09-16 15:46 發表評論
    ]]>
    主站蜘蛛池模板: 免费a级毛片无码a∨蜜芽试看| 亚洲VA成无码人在线观看天堂| 亚洲精品无码永久在线观看| 在线亚洲人成电影网站色www | 免费看的成人yellow视频| mm1313亚洲精品国产| 久久精品国产亚洲AV大全| 在线91精品亚洲网站精品成人| 国产在线国偷精品免费看| 日韩版码免费福利视频| 亚洲日韩精品无码专区网址| 亚洲一久久久久久久久| 在线观看黄片免费入口不卡| 好男人看视频免费2019中文 | 久久精品亚洲AV久久久无码| 一边摸一边桶一边脱免费视频| 日本zzzzwww大片免费| 亚洲中文字幕日产乱码高清app| 亚洲日韩亚洲另类激情文学| 久久精品免费一区二区三区| heyzo亚洲精品日韩| 2020久久精品亚洲热综合一本| 国产午夜无码精品免费看动漫| 免费不卡中文字幕在线| 亚洲人成77777在线播放网站不卡| 永久免费A∨片在线观看| 亚洲第一页综合图片自拍| 亚洲乱码在线观看| 57pao国产成永久免费视频| 亚洲精品美女久久777777| 性色av极品无码专区亚洲| 久久精品a一国产成人免费网站 | 成年人免费观看视频网站| 国产亚洲美日韩AV中文字幕无码成人| 亚洲综合国产成人丁香五月激情| 日韩av无码久久精品免费| 国产亚洲精品成人AA片新蒲金 | v片免费在线观看| 在线免费视频一区| 亚洲一区二区三区亚瑟| 久久午夜夜伦鲁鲁片免费无码|