I am building a Spring MVC app; I am using Spring Tool Suite 3.6.4 with TomCat8. When I run the web app and when I access to /greeting I got "Http Status 404 requested resource is not available" in the console I have neither error nor the message I am displaying with System.out.println.
Below my code. Please help web.xml http://ift.tt/1drxgYl" id="WebApp_ID" version="3.1"> fitTracker index.html index.htm index.jsp default.html default.htm default.jsp fitness fitness org.springframework.web.servlet.DispatcherServlet fitness /*
fitness-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:context="http://ift.tt/GArMu7"
xmlns:mvc="http://ift.tt/1bHqwjR"
xmlns:p="http://ift.tt/1jdM0fE"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/GArMu7 http://ift.tt/1tY3uA9
http://ift.tt/1bHqwjR http://ift.tt/YzZ6hD">
<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<context:annotation-config/>
<context:component-scan base-package="com.thewizardofoz.controllers.controllers"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
</beans>
HelloController.java
package com.thewizardofoz.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping(value="/greeting")
public String sayHello(Model model){
System.out.println("Hello Console");
model.addAttribute("greeting", "Welcome to our world!");
return "hello";
}
}
hello.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>${greeting}</h1>
</body>
</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>INDEX</h1>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire