Spring mvc 为什么我的JSTL if check不';不行?
我正在尝试使用SpringSecurity创建具有登录功能的简单应用程序。但我不能达到预期的效果。 jsp页面上的JSTL标记未通过测试,而scriplet代码通过了测试,这是我希望在应用程序中避免的 我的JSP页面Spring mvc 为什么我的JSTL if check不';不行?,spring-mvc,spring-security,jstl,conditional-statements,Spring Mvc,Spring Security,Jstl,Conditional Statements,我正在尝试使用SpringSecurity创建具有登录功能的简单应用程序。但我不能达到预期的效果。 jsp页面上的JSTL标记未通过测试,而scriplet代码通过了测试,这是我希望在应用程序中避免的 我的JSP页面 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/f
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Log in page</title>
</head>
<body>
<form action="<c:url value="/login"/>" method="POST">
<p>
<label for="username">Username</label>
<input type="text" id="username" name="username"/>
</p>
<p>
<label for="password">Password</label>
<input type="password" id="password" name="password"/>
</p>
<button type="submit" class="btn">Log in</button>
</form>
// This block of code is never executed
<c:if test="${error != null}">
Some test message
</c:if>
// While this one works fine
<%
if (request.getParameter("error") != null) {
out.write("error's value isn't null\n");
}
%>
</body>
</html>
Spring MVC控制器映射“/登录”请求的方法
这就是我所要求的:
我变了
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
到
据我所知,EL评估已停用,因此我手动激活了它
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String loginPage(Model model,
@RequestParam(value = "error", required = false) String error {
if (error != null) {
model.addAttribute("error", "Username or password is incorrect.");
}
return "login";
}
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>