您的位置:首页 > 编程语言 > Java开发

struts2 环境配置

2015-07-29 09:20 441 查看
以 2.1.7 版本为例,其他版本请参考struts2官网

一、导入jar包

struts2-core.jar //核心jar包

xwork-2.jar // xwork核心jar包

ognl.jar //ognl表达式

freemarker.jar //FreeMarker模板

commons-logging.jar //日志

commons-fileupload.jar //文件上传

commons-io.jar //文件上传依赖的包

二、编写 struts.xml 配置文件

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

</struts>


三、在 web.xml 中注册struts2过滤器

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: