读书人

struts2工程的配备

发布时间: 2012-08-31 12:55:03 作者: rapoo

struts2工程的配置

1、新建一个tomcat web工程


2、引入struts2的相关包


3、在工程web.xml中加入过滤器

?

<filter>     <filter-name>struts2</filter-name>     <filterclass>         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter      </filter-class></filter><filter-mapping>      <filter-name>struts2</filter-name>      <url-pattern>/*</url-pattern></filter-mapping>

?

4、添加struts.xml配置文件


??? struts.xml默认添加位置在classpath下

<?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>    <constant name="struts.enable.DynamicMethodInvocation" value="false" />    <constant name="struts.devMode" value="false" />    <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"></constant>    <package name="user" namespace="/user" extends="struts-default">        <action name="*" method="{1}"><result name="create-success">/WEB-INF/user/list_user.jsp</result>        </action>    </package>    <!-- Add packages here --></struts>
?

?

读书人网 >软件架构设计

热点推荐