我正在开发Struts 1.x到Spring 4迁移。
我首先在Struts 1.x项目中创建了一个POC,我在其中使用Get方法创建了SpringConfig.xml,WebConfig.xml,SpringRequestFilter.java和DemoController。我正在修改任何.do GET请求URI到Democontroller路径,它正在调用我的DemoController get方法。
现在我想将一个动作java类更改为controller。我现在做了以下更改我无法使用模型在控制器上命中。
这是代码,
SpringRequestFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
String requestURI = request.getRequestURI();
if (requestURI.startsWith("/workbench/securityPolicy.do")) {
String newRequestURI = requestURI.replaceFirst("/workbench/securityPolicy.do",
"/controller/securityPolicy");
req.getRequestDispatcher(newRequestURI).forward(req, res);
} else {
fc.doFilter(req, res);
}
}
操作 - >控制器类
@Controller
@RequestMapping("/controller")
public class SecurityPolicyAction {
@RequestMapping(value="/securityPolicy", method=RequestMethod.GET)
public String executeViewSecurityPolicy(@ModelAttribute("viewSecurityPolicyForm") ViewSecurityPolicyForm securityPolicyForm,
final HttpServletRequest request, final HttpServletResponse response) throws Exception {
String requiresStrongPassword = null;
viewSecurityPolicy.jsp
<html:form action="securityPolicy" commandName="viewSecurityPolicyForm" method="GET">
ViewSecurityPolicyForm.java - &gt; Pojo文件
使用此配置,我无法在设置Model对象的方法上触发控制器/操作类。如果我使用没有ModelAtrribute参数的简单方法而不是正确调用控制器方法。