struts-2.5.10.1 版本的HelloWorld
来源:互联网 发布:淘宝裤子女装 编辑:程序博客网 时间:2024/06/17 12:12
struts-2.5.10.1版本的HelloWorld
大家好!由于旧版本的Struts2存在漏洞,就用新版本的Struts2创建了一个简单的HelloWorld例子,同大家共享一下。碰到问题可以跟大家一起探讨。
1.我的环境: JDK 1.8 ,eclipse:Luna Service Release 1 (4.4.1),apache-tomcat-8.0.8,win7 64位操作系统。
2.配置步骤。
1)创建动态web工程
2).加入lib包并且应用,可以到官网下载,也可以到我的资源下载:http://download.csdn.net/detail/suxiaoluhaha/9789584
注意:引用这12个包时,javassist-3.20.0.GA.jar这个包解析不了,我就换成老版本的javassist-3.11.0.GA.jar这版本。
原先老版本有个xwork-core jar的,新版本的xwork-core jar 包被合并到struts2-core jar包里。
3)配置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"> <display-name>struts-2.5.10.1</display-name> <!-- 配置struts2 的filter --> <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>注意:老版本的 filter-class 是<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
新版本的filter-class 是<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
选哪个可以在 struts2-core jar 里找到StrutsPrepareAndExecuteFilter类,然后确定用哪个路经。
4).配置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="fis" extends="struts-default"> <action name="hello" class="com.fis.struts2.test.Hello" method="sayHello"> <result name="ok">/WEB-INF/views/result.jsp</result> </action> </package></struts>
5).填充Action里的配置信息。
①name="hello"
②class="com.fis.struts2.test.Hello"
③method="sayHello" 和 <result name="ok">
④结果路径:<result name="ok">/WEB-INF/views/result.jsp</result>
6). 运行测试
如果要源码可以到我github下载: https://github.com/yxzyh/struts-2.5.10.1
- struts-2.5.10.1 版本的HelloWorld
- annotation版本的helloworld
- ios版本的helloworld
- ios版本的helloworld
- Nginx版本的“helloworld”
- struts-helloworld
- 几个特别版本的HelloWorld
- 建立Annotation版本的HelloWorld
- OSGi版本的HelloWorld实践
- 01-Bootstrap版本的HelloWorld
- Spring MVC版本的helloworld
- Struts-2.5.10版本遇到的问题
- 最简单的Struts 2 HelloWorld
- eclipse+Struts 2.3.4.1的HelloWorld
- eclipse+Struts 2.3.4.1的HelloWorld .
- Hibernate的Annotation版本的HelloWorld
- Servlet版本的HelloWorld(附环境配置)
- Struts2的Helloworld(版本:2.0.14)
- SpringMVC+easyUI中datagrid分页实现(转载)
- 采用分治法求最大子列
- 2017年3月22日
- 矩估计和最大似然估计关系
- Centos7 下安装PHP7 phpredis扩展报错解决办法
- struts-2.5.10.1 版本的HelloWorld
- 盒子垂直居中
- 数据分析:留存率曲线拟合
- 深入理解KVC与KVO
- Linux常用命令大全
- C++之‘nullptr’ was not declared in this scope
- Docker命令
- Linux 交换分区,回环设备
- 知识图谱学习之neo4j数据库(三)