【发布时间】:2018-07-31 04:59:09
【问题描述】:
我对 thymeleaf 非常陌生,我一直致力于在 jsp 中运行良好的项目。现在我必须转向 Spring Boot,我面临一些问题。当用户请求映射 /staff 和 userClickManager 获得值 true 并且我想更改 index.html 同一文件中的内容时,我有我想要的这个控制器
@RequestMapping(value = "/", method = RequestMethod.GET)
private ModelAndView index() {
ModelAndView model = new ModelAndView("index");
model.addObject("title", "Home");
model.addObject("userClickHome", true);
return model;
}
@RequestMapping("/staff")
private static ModelAndView staff(){
ModelAndView view = new ModelAndView("index");
view.addObject("title", "Manager");
view.addObject("userClickManagers", true);
return view;
}
这是我的 旧 jsp 代码的原型,只希望它们在百里香中,谢谢。
<c:if test="${userClickHome==true}">
<!-- load the manager.jsp file -->
<%@include file="homeContent.jsp" %>>
</c:if>
<c:if test="${userClickManagers==true}">
<!-- load the manager.jsp file -->
<%@include file="Manager.jsp" %>
</c:if>
【问题讨论】:
-
见stackoverflow.com/questions/22538900/…。而不是 addObject 使用 addAttribute.
-
好吧,让我检查一下,谢谢
-
它没有集成到同一个 index.html 文件中,而是在单击所需内容时打开 _blank 页面
标签: java jsp spring-mvc spring-boot thymeleaf