1

我无法使用 jstl 获取模型

控制器.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 时,它没有显示任何东西。

更新.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>
4

0 回答 0