struts2学习笔记
环境搭建
必须的lib包(这里没有写版本号,注意版本):
- commons-logging.jar
- fileupload.jar
- freemarker.jar
- ognl.jar
- struts2-core.jar
- xwork-core.jar
- commons-in.jar
- javassist.jar
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> </filter-mapping>
在src下创建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> </struts>