jsp路径问题

${pageContext.request.contextPath}等价于<%=request.getContextPath()%>或者可以说是<%=request.getContextPath()%>

意思就是取出部署的应用程序名或者是当前的项目名称

比如我的项目名称是SpringMVC 在浏览器中输入为http://localhost:8080/ch12test/user/input

${pageContext.request.contextPath}或<%=request.getContextPath()%>取出来的就是http://localhost:8080/ch12test/,

比如我的项目

 

 

 

经过

@RequestMapping(value = "/save")
public String addUser(@ModelAttribute User user, Model model) {
if (userService.addUser(user)) {
logger.info("成功");
return "redirect:/user/list";
}

......

}

的转发后就到了http://localhost:8080/ch12test2/ch12test2/user/input, 。

产生了路径的问题,因此需要对路径改变,将  jsp中的路径改为

就会正确转到应该的界面了 http://localhost:8080/ch12test2/user/input,

 


posted @ 2019-09-22 09:28  Black丨White  阅读(128)  评论(0)    收藏  举报