无法通过使用jstl从Model和View获取模型

时间:2017-11-14 03:57:06

标签: spring-mvc jstl modelandview

我无法使用jstl

获取模型

Controller.java

@RequestMapping(value="/update/{url_mapping}",method = RequestMethod.GET)
public ModelAndView updatePicture(@PathVariable String url_mapping) {
    Picture picture = new Picture();
    String url = url_mapping+".jpg";
    ModelAndView modelAndView =  new ModelAndView();

    picture = (Picture) pictureInfo.findPicture(Picture.class, url);
    modelAndView.addObject("picture", picture);
    modelAndView.setViewName("redirect:/update.jsp");

    return modelAndView;
}

我试过它可以从db获取数据,但是当我使用modelandview将模型和视图传递给update.jsp时,它没有显示任何内容。

update.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <c:out value="${picture.url_mapping}"/>
</body>
</html>

0 个答案:

没有答案