搭建Struts2开发环境

1.需要的jar包(在tomcat6.0中测试):

commons-fileupload-1.2.2.jar,

commons-io-2.0.1.jar,

commons-lang-2.5.jar,

freemarker-2.3.16.jar,

javassist-3.11.0.GA.jar,

ognl-3.0.1.jar,

struts2-core-2.2.3.jar,

xwork-core-2.2.3.jar (当需要上传、下载文件是就需要commons-io-2.0.1.jar)

2.在web.xml文件中加入以下拦截器

<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> <!--“/*”是约定俗称的,“*.action”也可以--> </filter-mapping>

3.配置struts.xml文件(放在eclipse的src目录下)

<?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.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <action name="index"> <result>/index.jsp</result> </action> </package> </struts>

你可能感兴趣的:(eclipse,tomcat,struts,jar,action,encoding)