Я пытаюсь сделать что-то с разрешениями для гостя и пользователя, и я что-то сделал, но он не работает, появляется ошибка, которая отображается в заголовке.Spring MVC, JSP - Обязательный параметр boolean 'guest' нет
/дома и/вход/дома используют один и тот же JSP
Я хочу, чтобы «зарегистрировать» и «войти» не будет отображаться для зарегистрированных пользователей
MainController:
@Controller
public class MainController {
DBConnection db = new DBConnection();
@RequestMapping(value = "/home.html", method = RequestMethod.GET)
public ModelAndView HomePage(@RequestParam boolean guest) {
User user = new User();
user.setGuest(guest);
user.isGuest();
ModelAndView main = new ModelAndView("Main");
return main;
}
@RequestMapping(value = "/logged/home.html", method = RequestMethod.GET)
public ModelAndView homePageforUsers(@RequestParam boolean loggeduser) {
User user = new User();
user.setUser(loggeduser);
user.isUser();
ModelAndView main = new ModelAndView("Main");
return main;
}
main.jsp:
<c:if test="${user.isUser()}">
<div class="cart">
<a href="http://localhost:8080/OnlineShop/cart.html"
style="text-decoration: none; color: #000"> Cart </a>
<div class="logout">
<a href="http://localhost:8080/OnlineShop/home.html"
style="text-decoration: none; color: #000"> Log out </a>
</div>
</div>
</c:if>
<c:if test ="${user.isGuest()}">
<div class="register">
<a href="http://localhost:8080/OnlineShop/registration.html"
style="text-decoration: none; color: #000"> Register </a>
</div>
<div class="login">
<a href="http://localhost:8080/OnlineShop/login.html"
style="text-decoration: none; color: #000"> Log in </a>
</div>
</c:if>
Я решил его уже с помощью model.addAttribute и впрыскивать значение в jsp, но спасибо :) – dante