Spring boot JSP到Thymeleaf逻辑&;正向语法等价
在尝试从JSP移动到Thymeleaf时——在前者中,Spring启动初始类(使用main方法)对登录的用户执行了一些验证,如果有效,则会显示banner.JSP。在同意banner.jsp的声明后,用户将单击“Ok”(在banner.jsp上),这称为index.jsp,使用Spring boot JSP到Thymeleaf逻辑&;正向语法等价,spring-boot,jsp,thymeleaf,Spring Boot,Jsp,Thymeleaf,在尝试从JSP移动到Thymeleaf时——在前者中,Spring启动初始类(使用main方法)对登录的用户执行了一些验证,如果有效,则会显示banner.JSP。在同意banner.jsp的声明后,用户将单击“Ok”(在banner.jsp上),这称为index.jsp,使用 。 这最终带来了webapp 在转换成Thymeleaf的过程中,我可以得到 索引中的片段(now.html)。我想大概是 <div th:if="${empty Validated}" th:action="@{
。
这最终带来了webapp
在转换成Thymeleaf的过程中,我可以得到
索引中的片段(now.html)。我想大概是
<div th:if="${empty Validated}" th:action="@{/do/Index}"></div>
你能发布你的控制器类吗?“Validated”是参数吗?
I've tried some syntax variations of the <div th:if="${empty Validated}" th:action="@{/do/Index}"></div> without success.
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<!--<c:if test='${empty Validated}'><jsp:forward page="/do/Index" /></c:if>-->
<div th:if="${empty Validated}" th:action="@{/do/Index}"></div>
</body>
</html>
package mil.dfas.springmvc.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* @author David Higgins
*/
@Controller
public class LMSSpringController {
private static final Logger log = LoggerFactory.getLogger(LMSSpringController.class);
@Value("${messages.banner:default-value}")
private String message = "HelWd";
@RequestMapping("/banner")
public String welcome(Model model) {
log.info("Config Example");
System.out.println("LMS Controller");
model.addAttribute("msg","Forward Handled");
return "banner";
}
/* @GetMapping("/index")
public String indexHandler() {
System.out.println("index cont");
return "forward:/do/Index";
}*/
@RequestMapping(value = "/index", method = RequestMethod.POST)
public ModelAndView indexHandler(ModelMap model) {
model.addAttribute("attribute", "index");
System.out.println("index cont");
return new ModelAndView("forward:/do/Index", model);
}
@RequestMapping("/")
public void handleRequest() {
throw new RuntimeException("test exception");
}
}