Struts2学习笔记之为Web应用添加Struts2支持

1、拷贝必需的jar包至WebContent/WEB-INF/lib目录下。

必需的jar包如下:

commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
freemarker-2.3.19.jar
javassisi-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.15.jar
xwork-core-2.3.15.jar

 

 

2、在web.xml中配置Struts2的核心Filter

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Struts2Study</display-name>

  <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>
</web-app>

 

3、在Web应用的类加载路径下添加struts.xml配置文件。

类加载路径指的是WEB-INF/class路径,对应于eclipse的src文件夹(即把struts.xml添加至src根目录下)



 

猜你喜欢

转载自guoying252166655.iteye.com/blog/2043201