配置Struts2

来源:互联网 发布:题目解答软件 编辑:程序博客网 时间:2024/06/14 12:57

核心包:   9个 +4常用扩展
/TestStruts2/WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar //核心
/TestStruts2/WebContent/WEB-INF/lib/commons-io-2.2.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/commons-lang3-3.2.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/commons-logging-1.1.3.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/freemarker-2.3.19.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/javassist-3.11.0.GA.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/ognl-3.0.6.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/struts2-core-2.3.16.1.jar//核心
/TestStruts2/WebContent/WEB-INF/lib/xwork-core-2.3.16.1.jar//核心

核心包下载地址:http://people.apache.org/builds/struts/2.3.16.1/;

----------------------------扩展--------------------------------
/TestStruts2/WebContent/WEB-INF/lib/json-lib-2.2.3-jdk15.jar//解析json  所需包
/TestStruts2/WebContent/WEB-INF/lib/json-lib-2.3-jdk13.jar//解析json  所需包
/TestStruts2/WebContent/WEB-INF/lib/mysql-connector-java-5.1.7-bin.jar /连接数据库的jar包
/TestStruts2/WebContent/WEB-INF/lib/struts2-json-plugin-2.3.15.1.jar//  传JSON数据格式jar包

/TestStruts2/WebContent/WEB-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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">
    <display-name>Struts2</display-name>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

/TestStruts2/src/struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>

<package name="JsonTest" extends="json-default" namespace="/">
      <action name="getJson"  class="com.action.jsonData" method="getDateFromMySQL">
            <result name="getJsonData" type="json" >
                 <param name="root">list</param>
            </result>
        </action>
    </package>
    <!-- Add packages here -->

</struts>

 

0 0
原创粉丝点击