我的要求是根据所选值返回视图(选择表单)
视图.jsp:
<form method="post" action="/aaa">
<select id="attr1" name="attr1">
<option value="1">A</option>
<option value="2">B</option>
</select>
<input type="submit" value="submit" />
</form>
如果选择的值是 A(1),则 view1 是要显示的视图,否则显示 view2。
控制器方法:
@RequestMapping(value = "/aaa", method = RequestMethod.POST)
public ModelAndview methodName ( HttpServletRequest request,
HttpServletResponse response){
attribute=request.getParameter("attr1");
if (attribute==1) return new ModelAndView("view1")
else if (attribute==2) return new ModelAndView ("view2")
}
我该怎么做?谢谢。