How to remove the action suffix extension in Struts 2
2015-09-17 09:57
666 查看
In Struts 2, all action class has a default suffix
To access the “
Action URL : http://localhost:8080/Struts2Example/SayStruts2.action
Now you can access the “
Action URL : http://localhost:8080/Struts2Example/SayStruts2.html
Now you can access the “
Action URL : http://localhost:8080/Struts2Example/SayStruts2
.actionextension. For example,
<struts> <package name="default" namespace="/" extends="struts-default"> <action name="SayStruts2"> <result>pages/printStruts2.jsp</result> </action> </package> </struts>
To access the “
SayStruts2″ action class, use the following URL :
Action URL : http://localhost:8080/Struts2Example/SayStruts2.action
Configure the action extension
Struts 2 is allow to configure the action extension easily, to change it, just declare a constant “struts.action.extension” value :
1. html extension
Change the action class to.htmlextension.
<struts> <constant name="struts.action.extension" value="html"/> <package name="default" namespace="/" extends="struts-default"> <action name="SayStruts2"> <result>pages/printStruts2.jsp</result> </action> </package> </struts>
Now you can access the “
SayStruts2″ action class via
Action URL : http://localhost:8080/Struts2Example/SayStruts2.html
2. No extension
Change the action class to empty extension.<struts> <constant name="struts.action.extension" value=""/> <package name="default" namespace="/" extends="struts-default"> <action name="SayStruts2"> <result>pages/printStruts2.jsp</result> </action> </package> </struts>
Now you can access the “
SayStruts2′ action class via
Action URL : http://localhost:8080/Struts2Example/SayStruts2
相关文章推荐
- JQuery+Strusts1.x无刷新登录
- java struts常见错误以及原因分析
- Struts之logic标签库详解
- struts2的select标签用法实例分析
- SSH框架网上商城项目第20战之在线支付平台
- java中struts 框架的实现
- sprng和struts有什么区别?
- SpringMVC+MyBatis项目总结(三)
- MyEclipse7.5+JDK1.6+Tomcat6+Struts1.3+MySQL4.1开发演示
- struts使用拦截器注解
- 懒到极致:对mybatis的进一步精简
- 浅谈struts1和struts2框架(转载+整理)
- Maven搭建struts2+spring+hibernate环境(二)
- Maven搭建struts2+spring+hibernate环境(三)
- 国内首创Java开发者的技术体系
- Struts知识
- struts 获取客户端真实ip
- 转载--Struts1.1 validation framework 使用中的若干经验
- 初探Struts + Hibernate(二) --从HQL中取值