Struts2 get the source request URI

I want to get the current uri request from a jsp page in struts2 webapp. I can do this in action using the following:

ServletActionContext.getRequest().getRequestURI() 

... and I assumed that technically I could create an action property that simply returns this value, but I would prefer not to write it to the action, is there a way to get the same value in jsp using the ognl expression?

EDIT: After playing a little, I realized that even if I can get the HttpServletRequest.getRequestURI () value on the jsp page by the time it is received, it will be changed to the jsp path and not to the original request URI. not what i want.

So, instead of what I did, write a hook that takes the value at an early stage before the request is sent to the jsp file, and then save it to the value stack, which I can then attribute to it in jsp. This may be the only solution, but if someone knows different, then enlighten me.

+4
source share
1 answer
 <s:url/> 

This Tiles2 Struts Switch Locale question shows a tag application and shows how to support parameters on a URL (which may be useful later).

+1
source

Source: https://habr.com/ru/post/1336863/


All Articles