使用Struts2版本为:struts-2.3.16.3 下载地址:http://struts.apache.org/
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.16.3.jar
xwork-core-2.3.16.3.jar
如果struts2版本不一样,以上jar包具体版本号或许稍微有差别
在struts-2.3.16.3\apps目录下然后解压struts2-blank.war文件
在WEB-INF\lib目录下会有struts2必需的jar包,或可全部导入。
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="build" extends="struts-default"> <action name="login" method="login" class="com.itmyhome.Login"> <result name="success">index.jsp</result> </action> </package> </struts>
package com.itmyhome; public class Login { public String login(){ System.out.println("***已进入***"); return "success"; } }
<body> <h1>恭喜,Struts2框架搭建成功!</h1> </body>
浏览器中输入 http://localhost:8080/struts_frame/login
如页面正常跳转 显示如下内容,则Struts2框架搭建成功
框架结构图:
源码下载:已上传 待显示
原文:http://blog.csdn.net/itmyhome1990/article/details/36186059