扫码关注官方订阅号
正常情况下 http://127.0.0.1:8080/struts2-showcase/index.action我想访问 http://127.0.0.1:8080/struts2-showcase/ 直接返回和上面一样的效果,不需要跳转.请问怎么配置呢?
http://127.0.0.1:8080/struts2-showcase/index.action
http://127.0.0.1:8080/struts2-showcase/
欢迎选择我的课程,让我们一起见证您的进步~~
struts2中是允许配置默认后缀的,共有两种使用方式:1.有后缀的配置如下,配置文件如下:
<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>
访问"SayStruts2"action类可以通过:http://localhost:8080/Struts2Example/SayStruts2.html 2.无后缀的配置文件:
http://localhost:8080/Struts2Example/SayStruts2.html
<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>
访问"SayStruts2"action类可以通过: http://localhost:8080/Struts2Example/SayStruts2
http://localhost:8080/Struts2Example/SayStruts2
========================================================补充:struts2配置默认首页:方法一:
<default-action-ref name="SayStruts2"></default-action-ref> <action name="SayStruts2"> <result> struts2-showcase/index.action</result> </action>
方法二:定义过滤器继承struts的过滤器,把上下文根路径排除,不让根路径请求转发到struts的过滤器中去,同时在web.xml定义默认的欢迎页。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
struts2中是允许配置默认后缀的,共有两种使用方式:
1.有后缀的配置如下,配置文件如下:
访问"SayStruts2"action类可以通过:
http://localhost:8080/Struts2Example/SayStruts2.html2.无后缀的配置文件:
访问"SayStruts2"action类可以通过:
http://localhost:8080/Struts2Example/SayStruts2========================================================
补充:struts2配置默认首页:
方法一:
方法二:定义过滤器继承struts的过滤器,把上下文根路径排除,不让根路径请求转发到struts的过滤器中去,同时在web.xml定义默认的欢迎页。