Reputation: 153
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<!-- jQuery -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<c:if test="${error}">
<script>
alert("You must have something...");
</script>
</c:if>
</body>
</html>
<c:if test="${error}">
<script>
alert("You must have something...");
</script>
</c:if>
@RequestMapping(value = "/sample/board.do", method = RequestMethod.POST)
public ModelAndView updateBoard(@ModelAttribute HistoryBoard historyBoard) throws Exception {
ModelAndView mv = new ModelAndView("redirect");
mv.addObject("error", true);
return mv;
}
and it make url http://localhost:8080/test/board/board.do?error=true
but c:if
tag doesn't work
<c:if test="${not empty error}">
<h1>TEST</h1>
</c:if>
c:if
not empty doesn't work too.
how to fix this tag?
Upvotes: 0
Views: 1669
Reputation: 1
The error is a parameter, not a scope variable.
<c:if test="${not empty param.error}">
<h1>TEST</h1>
</c:if>
Upvotes: 1