avatar
Spring MVC question.# Java - 爪哇娇娃
g*g
1
Used to use Struts, and here's a question for Spring MVC.
After submit a form successfully, I want to return to
main menu which should be a link like main.html (map .html to spring
controllers).
Now the question is, with InternalResourceViewResolver as ViewResolver,
prefix and suffix specified, /WEB-INF/jsp/ and .jsp respective,
how do you do the redirect?
Do I have to write a dummy jsp page which forwards to main.html?
avatar
m*t
2
At the end of your form controller, return "redirect:action-name" for the
view name. Replace "action-name" with the action name to enter your main
page.
avatar
g*g
3
cool, but what's the best practice?
If I need to do this "redirect:/main.html" in many controller,
isn't that kind of hard coding. Any convenient way to inject
a view or something and if I have to change main controller url, I change it
in xml file for only once.

【在 m******t 的大作中提到】
: At the end of your form controller, return "redirect:action-name" for the
: view name. Replace "action-name" with the action name to enter your main
: page.

avatar
m*t
4

it
I suppose you could do something like this:



Then in every controller where you need to go back to the main page
afterwards:


【在 g*****g 的大作中提到】
: cool, but what's the best practice?
: If I need to do this "redirect:/main.html" in many controller,
: isn't that kind of hard coding. Any convenient way to inject
: a view or something and if I have to change main controller url, I change it
: in xml file for only once.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。