java - How to manage URLs on errors on Spring MVC? -


i have webapp spring mvc 3.0.4.release.

i have following scenario:

1) enter search web page path: search.html
2) click search , post path: searchresults.hmtl
3) when click search result, post searchresults/enterresult.html
4) let assume controller raises exception...
5) need return searchresults.html page previous search.

i can't use forward, because maintains path searchresults/enterresults.html, if click o search result builds following inexistent path: searchresults/searchresults/enterresults.html

do know how manage problem?

if error occurs, why not redirect:searchresults.html instead of forwarding it? if want send error message displayed in page, can add them parameters, this: redirect:searchresults.html?error_message=yada.

by way, if avoid using relative url when constructing search result form action, shouldn't searchresults/searchresults/enterresults.html problem in first place. seem doing post on enterresults.html instead of /your-app/searchresults/enterresults.html if fix this, won't need perform redirect mentioned above.

what i'm trying here is:

... instead of doing this...

<form action="enterresults.html" method="post">     ... </form> 

... this...

<form action="${pagecontext.request.contextpath}/searchresults/enterresults.html" method="post">     ... </form> 

this way, doesn't matter if forwarded url retains previous url or not. post right action.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -