controller code
package com.hp.controller; import org.springframework.stereotype.Controller; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller @RequestMapping("/blog") public class BlogController { @RequestMapping("/{id}") public ModelAndView blog(ModelAndView mv,@PathVariable("id") Integer id){ mv.addObject("msg", id); mv.setViewName("blog"); return mv; } }
jsp page that accepts data
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!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> ${msg} </body> </html>
The running result is as shown in the figure EL expression does not work
Solution
One is to add this sentence to the jsp page
<%@page isELIgnored="false" %>
Then it is displayed normally. As shown in the figure