I ' m learning the Spring Framework, and I ' m doing the Helloweb tutorial on Tutorialspoint, and I can ' t get it working. I ' m using Spring MVC 4.0, and I ' m deploying my app from Netbeans 8.0 to a Glassfish Server. Http://www.tutorialspoint.com/spring/spring_mvc_hello_world_example.htm
I looked for similar problems-on-site and on other sites as well, but the suggested solutions didn ' t work for me . I would really appreciate some help, because I ' m pretty sure I ' m missing something basic here.
Here is my relevant files:
Xml
<?xml version= "1.0" encoding= "UTF-8"? ><web-app version= "3.1" xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee Http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "><display-name>spring MVC application</disp Lay-name><context-param> <param-name>contextConfigLocation</param-name> <param-value> /web-inf/helloweb-servlet.xml</param-value></context-param><listener> <listener-class> o Rg.springframework.web.context.ContextLoaderListener </listener-class></listener><servlet> <servlet-name>HelloWeb</servlet-name> <servlet-class> Org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>2</ Load-on-startup></servlet><servlet-mapping> <servlet-name>helloweb</servlet-naMe> <url-pattern>/</url-pattern></servlet-mapping><session-config> < Session-timeout> </session-timeout></session-config></web-app>
Helloweb-servlet.xml
<?xml version=‘1.0‘ encoding=‘UTF-8‘ ?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"><context:component-scan base-package="com.tutorialspoint" /><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/jsp/" /><property name="suffix" value=".jsp" /></bean></beans>
hello.jsp
<%@ page contentType="text/html; charset=UTF-8" %>
Hellocontroller.java
package com.tutorialspoint;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.ui.ModelMap;@Controller@RequestMapping("/hello")public class HelloController{ @RequestMapping(method = RequestMethod.GET) public String printHello(ModelMap model) { model.addAttribute("message", "Hello Spring MVC Framework!"); return "hello"; }}
You had a single controller in your app, mapped to (that's what /hello
@RequestMapping("/hello")
means). The URL for this controller is thus http://localhost:8080/HelloWeb/hello
.
No mapping found for HTTP request with URI [/helloweb/] in Dispatcherservlet with Name ' Helloweb ' Spring MVC