Struts2學(xué)習(xí)

          幾年前學(xué)習(xí)了一陣子Struts2,也開發(fā)了些小項(xiàng)目,后來工作變動(dòng),幾年沒動(dòng)技術(shù),這兩天又想撿起來,發(fā)現(xiàn)一些配置有了變化,重新學(xué)習(xí),記錄些內(nèi)容,供自己查詢。

          環(huán)境沒敢用最新的,MyEclipse用的是8.5的版本,Tomcat最終選擇了6,JDK也是用的7,Struts2的版本2.3.16.3。通常的配置沒什么要記錄的,主要記錄下出問題的地方:
          1、Tomcat
          從MyEclipse啟動(dòng)Tomcat一直報(bào)錯(cuò),后來下載了一個(gè)tcnative-1.dll文件才解決,版本要求比較嚴(yán)格,對(duì)于Tomcat6.0.41而言,這個(gè)動(dòng)態(tài)鏈接庫(kù)版本要求是1.1.30,1.1.3都不行,不知道有什么區(qū)別,將文件拷貝到j(luò)re/bin下即可。
          2、web.xml文件內(nèi)容
           1 <?xml version="1.0" encoding="UTF-8"?>
           2 <web-app id="WebApp_9" 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">
           3 
           4     <display-name>Struts Test</display-name>
           5 
           6     <filter>
           7         <filter-name>struts2</filter-name>
           8         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
           9     </filter>
          10 
          11     <filter-mapping>
          12         <filter-name>struts2</filter-name>
          13         <url-pattern>/*</url-pattern>
          14     </filter-mapping>
          15 
          16     <welcome-file-list>
          17         <welcome-file>index.html</welcome-file>
          18     </welcome-file-list>
          19 
          20 </web-app>
          21 
          3、struts.xml文件內(nèi)容
           1 <?xml version="1.0" encoding="UTF-8" ?>
           2 <!DOCTYPE struts PUBLIC
           3     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
           4     "http://struts.apache.org/dtds/struts-2.3.dtd">
           5 
           6 <struts>
           7 
           8    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
           9     <constant name="struts.devMode" value="true" />
          10 
          11     <package name="default" namespace="/" extends="struts-default">
          12 
          13         <default-action-ref name="index" />
          14 
          15         <global-results>
          16             <result name="error">/error.jsp</result>
          17         </global-results>
          18 
          19         <global-exception-mappings>
          20             <exception-mapping exception="java.lang.Exception" result="error"/>
          21         </global-exception-mappings>
          22         
          23         <action name="action名" class="java包名及類名">
          24         <result name="success">/調(diào)用的jsp頁(yè)面文件p</result>
          25         </action>
          26     </package>
          27 
          28     <include file="example.xml"/>
          29 
          30     <!-- Add packages here -->
          31 
          32 </struts>
          33 
          4、調(diào)用時(shí)發(fā)現(xiàn)action名定義了大小寫后,地址欄也要輸入相應(yīng)的大小寫,否則報(bào)錯(cuò)。這個(gè)問題困擾了好久。。。。。


          By SeeSea

          posted on 2014-07-16 10:47 SeesSea 閱讀(198) 評(píng)論(0)  編輯  收藏 所屬分類: JAVA

          <2014年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 仪征市| 德惠市| 莲花县| 江阴市| 二手房| 临夏市| 曲沃县| 景宁| 永年县| 东明县| 桐庐县| 方正县| 潼关县| 嘉祥县| 隆化县| 堆龙德庆县| 新丰县| 汨罗市| 黎城县| 新津县| 宜兰县| 高淳县| 宁津县| 双柏县| 托里县| 徐州市| 博爱县| 桐柏县| 雷波县| 织金县| 罗平县| 株洲县| 博乐市| 同仁县| 中西区| 澄城县| 杭州市| 乌鲁木齐县| 东兴市| 罗田县| 朝阳市|