2014年7月16日

          Struts2學習

          幾年前學習了一陣子Struts2,也開發了些小項目,后來工作變動,幾年沒動技術,這兩天又想撿起來,發現一些配置有了變化,重新學習,記錄些內容,供自己查詢。

          環境沒敢用最新的,MyEclipse用的是8.5的版本,Tomcat最終選擇了6,JDK也是用的7,Struts2的版本2.3.16.3。通常的配置沒什么要記錄的,主要記錄下出問題的地方:
          1、Tomcat
          從MyEclipse啟動Tomcat一直報錯,后來下載了一個tcnative-1.dll文件才解決,版本要求比較嚴格,對于Tomcat6.0.41而言,這個動態鏈接庫版本要求是1.1.30,1.1.3都不行,不知道有什么區別,將文件拷貝到jre/bin下即可。
          2、web.xml文件內容
           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文件內容
           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">/調用的jsp頁面文件p</result>
          25         </action>
          26     </package>
          27 
          28     <include file="example.xml"/>
          29 
          30     <!-- Add packages here -->
          31 
          32 </struts>
          33 
          4、調用時發現action名定義了大小寫后,地址欄也要輸入相應的大小寫,否則報錯。這個問題困擾了好久。。。。。


          By SeeSea

          posted @ 2014-07-16 10:47 SeesSea 閱讀(198) | 評論 (0)編輯 收藏

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

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东源县| 原阳县| 金乡县| 突泉县| 郸城县| 自贡市| 门源| 南华县| 麟游县| 白朗县| 民勤县| 聂荣县| 嵊州市| 阳高县| 曲靖市| 龙江县| 平塘县| 呼伦贝尔市| 丰城市| 韩城市| 浮山县| 安顺市| 新晃| 绍兴县| 英山县| 共和县| 兴隆县| 将乐县| 临朐县| 高青县| 大冶市| 全椒县| 合山市| 岳池县| 长沙市| 龙井市| 东乌珠穆沁旗| 揭东县| 方城县| 克什克腾旗| 抚宁县|