1. 程式人生 > >spring MVC jsp頁面EL表示式無效

spring MVC jsp頁面EL表示式無效

轉載地址:詳情

ModelAndView’s model value is not displayed in JSP via EL

Problem

In Spring MVC development, developer try to set a value into a model, and display the value in JSP via EL, e.g ${msg}, but it just outputs the result as it is – ${msg}, not the “value” stored in the model. The EL is just not working in JSP, why?

Spring’s Controller

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class ABCController extends AbstractController{

	@Override
	protected
ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView model = new ModelAndView("HelloWorldPage"); model.addObject("msg", "hello world"); return model; } }

JSP page