struts2简单配置

来源:互联网 发布:mac 移动硬盘无法写入 编辑:程序博客网 时间:2024/05/21 17:35

导入的包:commons-logging-1.0.4.jar

freemarker-2.3.8.jar

jsonplugin-0.32.jar

ognl-2.6.11.jar

struts2-core-2.0.11.1.jar

xwork-2.0.4.jar


web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>test2</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <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>
</web-app>


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="Data" namespace="/Data" extends="struts-default">
<action name="Write" class="action.WriteDataAction"> 
    <result name="seccuss">/index.jsp</result>     
</action>
 </package>
 
   <package name="jsonTest" extends="json-default">  
        <action name="Read" class="action.ReadDataAction">               
            <result type="json">  
                <param name="root">responseJson.totalCont</param>  
            </result>  
        </action>  
      </package>
  </struts>


0 0
原创粉丝点击