乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      第一次接觸struts2.......

       levinLee 2010-07-23

      制作一個登陸表單,然后在另一個頁面顯示提交的內(nèi)容,很簡單的一個體驗式學(xué)習哈。

      先貼幾段和struts2無關(guān)的jsp代碼。

       
      1. //login.jsp   
      2. <form action="login.action" method="post">   
      3.         username:<input type="text" name="username" /><br />    
      4.         password:<input type="password" name="password" /><br />           
      5.         <input type="submit" value="submit" />   
      6.     </form>  

       

       
      1. //result.jsp   
      2. username : ${requestScope.username}<br />   
      3.     password : ${requestScope.password}  

       

      Action類:

       
      1. package cn.tshining.action;   
      2.   
      3. public class LoginAction {   
      4.     private String username;   
      5.     private String password;   
      6.     public String getUsername() {   
      7.         return username;   
      8.     }   
      9.     public void setUsername(String username) {   
      10.         this.username = username;   
      11.     }   
      12.     public String getPassword() {   
      13.         return password;   
      14.     }   
      15.     public void setPassword(String password) {   
      16.         this.password = password;   
      17.     }   
      18.     public String execute() throws Exception{   
      19.         return "success";   
      20.     }   
      21. }   
        

       

      首先接觸到了幾個重要的文件,像web.xml,struts.xml,還有幾個jar包。

      web.xml是整個站點的配置文件,要是用struts2就必須在 web.xml里“安裝”struts2框架,安裝方式就是在web.xml文件中增加<filter>(xml中這叫什么?記得不是很清楚!節(jié)點?)和<filter-mapping>節(jié)點。

       
      1. <filter>   
      2.     <filter-name>struts2</filter-name>   
      3.     <filter-class>   
      4.         org.apache.struts2.dispatcher.FilterDispatcher    
      5.     </filter-class>   
      6. </filter>  
      7.   
      8. <filter-mapping>   
      9.     <filter-name>struts2</filter-name>   
      10.     <url-pattern>/*</url-pattern>   
      11. </filter-mapping>  

       

      <url-pattern>/*</url- pattern>表示struts2將攔截客戶端所有請求

      然后需要在src目錄下新建struts.xml文件,內(nèi)容為

       
      1. <?xml version="1.0" encoding="UTF-8" ?>   
      2. <!DOCTYPE struts PUBLIC   
      3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"   
      4.     http://struts./dtds/struts-2.0.dtd>   
      5. <struts>   
      6.     <package name="struts2" extends="struts-default">   
      7.         <action name="login" class="cn.tshining.action.LoginAction">   
      8.             <result>/result.jsp</result>    
      9.         </action>   
      10.     </package>   
      11. </struts>   

       


       

      前面為xml的聲明,<package name="struts2" extends="struts-default">是包名,并繼承自struts-default,<action name="login" class="cn.tshining.action.LoginAction">,action的名字和jsp表單中一樣,class屬性為定義的action類。result屬性默認值為 “success”,并會將執(zhí)行成功的結(jié)果轉(zhuǎn)發(fā)至result.jsp。

      關(guān)于用到的jar包,這個看教程上寫著只用commons-logging- 1.0.4.jar,freemarker-2.3.15.jar,ognl-2.7.3.jar,struts2-core- 2.1.8.jar,xwork-core-2.1.6.jar這5個jar包,但是我拷到工程中卻發(fā)現(xiàn)Tomcat產(chǎn)生嚴重錯誤,后來發(fā)現(xiàn)有幾個類沒找到,仔細觀察發(fā)現(xiàn)少了commons-fileupload-1.2.1.jar

      不知道是版本原因還是什么,現(xiàn)在暫時還不了解。

      今天學(xué)到的就是這些基本的配置,做了一個小例子,收獲還是有的,明天接著……

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多