如何刪除Struts2動作的後綴擴展名

在Struts2中,所有動作類有一個默認的後綴 .action 擴展。 例如,

pages/printStruts2.jsp

如要訪問「SayStruts2」動作類,需要使用以下網址:

Action URL : http://localhost:8080/Struts2Example/SayStruts2.action

配置動作擴展


Struts 2是允許配置擴展名的,要對其進行更改,只需要聲明一個常數「struts.action.extension」值:

1. html 擴展

更改動作類爲 .html 的擴展名。

pages/printStruts2.jsp

現在,可以通過訪問「SayStruts2」動作類,使用如下URL:

Action URL : http://localhost:8080/Struts2Example/SayStruts2.html

2. 不使用擴展

動作類更改爲空的擴展。

pages/printStruts2.jsp

現在,可以通過如下的URL來訪問「SayStruts2' 動作類:

Action URL : http://localhost:8080/Struts2Example/SayStruts2

0 條評論,你可以發表評論,我們會進行改進
Comment author placeholder