【发布时间】:2017-09-27 12:46:46
【问题描述】:
您好,当在浏览器中点击不同的 url 时,我正在尝试更改 spring 控制器中的表单操作。
当我点击 url 时:http://localhost:8080/DEMO/shas/getExtLogin?key=11 然后操作在表单标签中附加为 action="/DEMO/shas/getExtLogin?key=11"。
但我需要在 LoginController.java getExternalLogin() 方法中将操作更改为 action="/DEMO/admin/",当点击 url 时:http://localhost:8080/DEMO/shas/getExtLogin?key=11
我的jsp代码:login.jsp
<form:form id="login" commandName="loginDO" clas="form-header">
我的 Java 代码:LoginController.java
@RequestMapping(value = "/getExtLogin", method = RequestMethod.GET)
public ModelAndView getExternalLogin(HttpServletRequest request) {
String extInd = request.getParameter("extInd");
request.getSession().setAttribute("extInd", extInd);
return new ModelAndView("jsp/login").addObject("loginDO", new LoginDO());
}
有什么方法可以在返回 ModelAndView 的同时改变 spring 控制器中的表单动作?
【问题讨论】:
-
我需要在java文件中设置而不是xml中的配置。