When I click on the link, I don’t find hello and I get an error

HTTP Status 404 - / MVC / hello
type Status report
message / MVC / hello
description of the requested resource is not available.

Project structure

enter image description here

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://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <a href="hello">Hello world</a> </body> </html> 

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://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <h3>${message}</h3> </body> </html> 

ControllerMain.java

 package edu.spring.java.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class ControllerMain { @RequestMapping(value = "/hello", method = RequestMethod.POST) public String helloWorld (ModelMap model){ model.addAttribute("message", "Hello world!!!!"); return "hello"; } } 

Web.xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name> Lesson</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/lib/lessonmvc-servlet.xml</param-value> </context-param> <servlet> <servlet-name>HelloWeb</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>HelloWeb</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> 

lessonmvc-servlet.xml

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <mvc:annotation-driven/> <context:component-scan base-package="edu.spring" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean> </beans> 

It seems everything is true, but why he does not find hello is not clear (((

update: Incorrectly placed web.xml. Placed in lib, moved to WEB-INF now for some reason Dispatcher does not see the spring, although everything is connected

INFO: Marking servlet HelloWeb as unavailable Jan 12, 2016 6:43:04 PM

org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet

/ MVC threw load () exception java.lang.ClassNotFoundException: org.springframework.web.servlet. WebappClassLoader.loadClass (WebappClassLoader.java:1547) at org. .apache.catalina.core.DefaultInstanceManager.newInstance (DefaultInstanceManager.java:142) at org.apache.catalina.core. .java: 1088) at org.apache.catalina.core.StandardContext.loadOnStartup (StandardContext.java sources176) at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5460) at org.apache.catalina. util.LifecycleBase.start (LifecycleBase.java:150) at org.apache. catalina.core.ContainerBase $ StartChild.call (ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase $ StartChild.call (ContainerBase.java:1549) at java.util.concurrent.FutureTask.run (Unknown Source ) at java.util.concurrent.ThreadPoolExecutor.runWorker (Unknown Source) at java.util.concurrent.ThreadPoolExecutor $ Worker.run (Unknown Source) at java.lang.Thread.run (Unknown Source)

  • one
    How do you deploy your application? - Vartlok
  • I run through eclipse in tomcat - Kleimosc
  • stop using already xml - MrGarison
  • Try to follow the instructions from here: stackoverflow.com/a/23766404/1646082 - Vartlok
  • Put the spring libraries in WEB-INF/lib . In general, I advise you to study maven or something like that. - Temka, too,

0