Struts2 better URLs with dot inside

北战南征 提交于 2020-01-03 17:05:09

问题


Let's say we need to get a login form with pre-defined username.

So if user goes to url:

//somehost:8080/myapp/auth/myusername

the action should take myusername as input parameter.

I tried http://www.struts2.info/blog/better-urls-with-struts2 as example, and it works great.

But if myusername contains dots, like:

//somehost:8080/myapp/auth/firstname.lastname 

, I get 404 error.

Is there any simple solution to use dots as a part of url parameter ?


回答1:


In struts.xml:

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

and in web.xml:

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Untested, but it should work



来源:https://stackoverflow.com/questions/22067742/struts2-better-urls-with-dot-inside

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!