I'm new to spring with java and I have the following controller and jsp
Controller:
@Controller
//mapeamento do nome
@RequestMapping("/hello")
public class HelloController {
//mapeamento do nome
@RequestMapping("/controller")
public ModelAndView hello() {
//caminho da pagina .jsp
return new ModelAndView("/hello/view", "message", "Bem-vindo ao spring");
}
}
Page index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="/hello/controller/"> Hello </a>
<br />
<a href="index.jsp"> Teste 1</a>
<br />
</body>
</html>
View.jsp page
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spring MVC</title>
</head>
<body>
<h2>${message }</h2>
</body>
</html>
The problem is. I normally start the application on tomcat. Access, " link " and the page displays correctly. But when I click on the 'Hello' link, it redirects to the link " link " ... correct, POREM, displays the error message:
"HTTP Status 404 - Not Found Type Status Report"
Message / hello / controller /
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
But if I put the direct link as " link " The page is displayed correctly.
In this case, how do I correct the problem and correctly display the page when the link is redirected to " link ?