Struts2修改请求URL 后缀名

本文介绍如何在Struts框架中通过配置文件更改请求URL的默认后缀,从默认的.action扩展名为.html或其他多种扩展名。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在struts.xml配置文件中增加节点

“<constant name="struts.action.extension" value="html" />”

就可将struts的请求URL后缀后改成*.html,而不是*.action

也就是说http://127.0.0.1:7001/SSH/newUserInfoAction.action

同等于http://127.0.0.1:7001/SSHNEW/newUserInfoAction.html

如不增加此节点。struts的请求URL后缀名默认为action。

其value的值可是为多个(以豆号分开),此时请求相同地址时value中的后缀名都有效。

如下设置

<constant name="struts.action.extension" value="action,jsp,html" />

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>
......
<constant name="struts.action.extension" value="html" />
</struts>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值