【发布时间】:2018-08-07 06:36:54
【问题描述】:
@RequestMapping(value = "/testmap", method = RequestMethod.GET)
public ModelAndView testmap(ModelAndView model) {
ModelMap map=new ModelMap();
String greetings = "Greetings, Spring MVC! testinggg";
model.setViewName("welcome");
map.addAttribute("message", greetings);
return model;
}
我有
${message}
在welcome.jsp 上。但它不会打印问候语。 能告诉我原因吗?
【问题讨论】:
-
为什么你认为它应该被打印? “印刷”到底是什么意思?
-
另外,您的问题到底是什么?标题和问题不同!
-
打印在哪里?请提供更多上下文,为什么要同时使用
Model和ModelAndView?您可以使用addObject(attributeName, attributeValue)方法在 ModelAndView 本身中设置模型属性。 -
我已经编辑了这个问题。我只需要它的共振。
-
您尝试过上面评论中建议的方式吗?
标签: spring-mvc model-view-controller