'Problem with showing message from model in view in Spring-MVC with (JSP+JSTL)
I'm learning spring-mvc now, and I have problem with getting messages from model and showing there in my .jsp views.
Who can explain why my code does't work?
This is my pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
My controller:
@Controller
public class SpittleController {
private MessagesDao messagesDao;
@Autowired
public SpittleController(MessagesDao messagesDao) {
this.messagesDao = messagesDao;
}
@RequestMapping(value = "/spittles", method = RequestMethod.GET)
public String spittles(Model model) {
model.addAttribute("message", messagesDao.showMessage());
return "spittles";
}
}
And my view:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Spittles</title>
</head>
<body>
<p>now showing message is - <c:out value="${message.message}"/></p>
</body>
</html>
In browser it's looks like: enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|