码迷,mamicode.com
首页 > 其他好文 > 详细

struts2.5的配置及其注意事项

时间:2016-10-07 20:17:01      阅读:4733      评论:0      收藏:0      [点我收藏+]

标签:

坑爹的apache,官方的jar包提供了一个struts2的运行最小jar包

 

技术分享

本以为下载这个最小的jar包放到lib目录下,配置一下就能运行,结果在tomcat环境下并不能运行成功,需要再加入两个jar包

技术分享

log4j和Javaassist,这两个jar包在之前的版本中也有,所以2.5的版本jar包没有很大变化,但是在配置文件中却有一点点小变化。

web.xml中的过滤器配置发生了变化

 

技术分享

 

但是其核心类依然是StrutsPrepareAndExecuteFilter.class,只要找到它的位置就行了。

 

这是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="action" namespace="/" extends="struts-default">
		<action name="login" class="com.action.login"  method="execute">
			<result name="success">/success.jsp</result>
		</action>
	</package>
</struts>

 

这是web.xml的配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	id="WebApp_ID" version="3.1">

	<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.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

</web-app>

 

作者: 做一个善良的人
链接:http://www.imooc.com/article/11907
来源:慕课网作者: 做一个善良的人
链接:http://www.imooc.com/article/11907
来源:慕课网

struts2.5的配置及其注意事项

标签:

原文地址:http://www.cnblogs.com/hello-daocaoren/p/5936417.html

(0)
(3)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!