转载地址:详情
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
本文讨论了在使用Spring MVC框架进行Web开发时,遇到ModelAndView对象中的属性无法通过EL表达式正确显示于JSP页面的问题,并提供了可能的解决方案。
711

被折叠的 条评论
为什么被折叠?



