Controller返回类的自动识别,WEB-INF,jsp位置
Controller:
@Controller
@RequestMapping("/params")
public class ParamsController {
@RequestMapping("/user")
public ModelAndView getParams(String username,int age) throws Exception{
ModelAndView mv=new ModelAndView();
mv.addObject("username",username);
mv.addObject("age",age);
mv.setViewName("result");
return mv;
}
}
springmvc.xml:
<!-- 视图解释类 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
其中视图解释类给出了result后缀.jsp,位置/jsp/中
posted on 2019-10-18 14:08 MIUMIUBLING 阅读(208) 评论(0) 编辑 收藏 举报