springMVC的controller的ModelAndView的值,无法在jsp显示问题
路径:http://localhost:8080/springmvcDemo_war/ControllerTest
controller
package com.xyj.controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ControllerTest implements Controller {
@Override
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
//创建ModelAndView对象
ModelAndView mav = new ModelAndView();
//向模型对象中添加一个名称为msg的字符串对象
mav.addObject("msg","第一个Spring MVC程序");
//设置返回视图路径
mav.setViewName("WEB-INF/jsp/welcome.jsp");
System.out.println("mav:"+mav);
return mav;
}
}
jsp
<%--
Created by IntelliJ IDEA.
User: ICBC
Date: 2021/12/18
Time: 18:09
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>hahhah</title>
</head>
<body>
{msg}
</body>
</html>
问题:
在jsp页面中写的是{msg},正确的写法是${msg}