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 here on this 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 are my relevant files:

web.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</display-name> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/HelloWeb-servlet.xml</param-value>
</context-param> <listener>
<listener-class>
org.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>
30
</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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://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" %>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>

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 have a single controller in your app, mapped to /hello (that's what @RequestMapping("/hello")means). The URL for that controller is thus http://localhost:8080/HelloWeb/hello.

No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name 'HelloWeb' Spring MVC的更多相关文章

  1. 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法

    首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...

  2. org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [XXX] in DispatcherServlet with name 'springMVC'

    在web.xml中添加 <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern ...

  3. No mapping found for HTTP request with URI [/webapp/] in DispatcherServlet with name 'SpringMVC'

    可能有如下几个原因: 1.是否设置了web目录,在IDEA中,web目录是这样的 如果没有设置,按照下面的方法设置: 选中要设置的模块,点击file.project structure,设置web.x ...

  4. spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js...

    问题:spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js... web.x ...

  5. springmvc No mapping found for HTTP request with URI in Dispatc

    springmvc No mapping found for HTTP request with URI in Dispatc 博客分类: Java Web springmvcspring MVCNo ...

  6. SpringMvc出现No mapping found for HTTP request with URI的终极解决办法

    No mapping found for HTTP request with URI 出现这个问题的原因是在web.xml中配置错了,如: <servlet> <servlet-na ...

  7. 问题 “No mapping found for HTTP request with URI [/rbiz4/uploadFile.html]” 的解决

    从以前的SpringMVC项目简化一下做个例子,结果出现了下面的错误: No mapping found for HTTP request with URI [/rbiz4/uploadFile.ht ...

  8. No mapping found for HTTP request with URI [] in DispatcherServlet with name 'appServlet'

    项目是使用SpringMVC (1)在浏览器中访问,后台总报错: No mapping found for HTTP request with URI [] in DispatcherServlet ...

  9. org.springframework.web.servlet.PageNotFound No mapping found for HTTP request with URI [/AssetRepair/assetRepairController/test.do] in DispatcherServlet with name 'assetrepair'

    web.xml文件配置: xxx-servlet.xml 我们可以发现DispatcherServlet会处理"jsp"后缀的请求;而模型视图后缀也是jsp的 如果这样配置会报以下 ...

  10. Spring3中js/css/jpg/gif等静态资源无法找到(No mapping found for HTTP request with URI)问题解决--转载

    原文地址:http://www.programgo.com/article/96083031845/ 最近项目中使用到Spring3,在感叹Spring3注解配置清爽的同时竟然出现了这个不和谐的事情, ...

随机推荐

  1. MVC3 Razor @RenderSection

    Mvc3的Razor视图引擎还提供了@RenderSection @RenderSection在母版页中占个位,然后让使用此母版页的子页自己去呈现他们的Section. 在母版页_Layout.csh ...

  2. HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...

  3. css网页自适应-1

    一."自适应网页设计"的概念 2010年,Ethan Marcotte提出了"自适应网页设计"(Responsive Web Design)这个名词,指可以自动 ...

  4. 史上最全然oophper php文件上传之文件类型相应表,ie,火狐各一份。

    ie 火狐 id 后缀名 php识别出的文件类型 0 gif image/gif 1 jpg image/jpeg 2 png image/png 3 bmp image/bmp 4 psd appl ...

  5. 怎样在VirtualBox 虚拟机中挂载共享目录

    啊.好长时间没写博客了.近期有点忙~~ 不得不说 VirtualBox 对于一些不想装非常多个系统又非常想实验新系统的人来说确实是神器: 哈哈.个人还是比較爱玩这些个各种各样的Linux 发型版的,可 ...

  6. POJ--1300--Door Man【推断无向图欧拉通路】

    链接:http://poj.org/problem?id=1300 题意:有n个房间.每一个房间有若干个门和别的房间相连.管家从m房间開始走.要回到自己的住处(0),问是否有一条路能够走遍全部的门而且 ...

  7. 一次搞定cocos2d-x的 Android.mk 文件

    cocos2d-x 打 android 包时要修改 Android.mk 文件,但每次修改很麻烦,如果源文件很多的话就坑死了,也可以写一个脚本来自动生成这个文件,但每次还要重新生成一下,将其修改下面的 ...

  8. [置顶] C++ Pirate: Lambda vs Bind

    Lambda 与 Bind的性能比较 转载请说明出处:http://blog.csdn.net/cywosp/article/details/9379403 先让我们看看下面函数: template ...

  9. windows 不能在 本地计算机 启动 Apache

    可能是Apache 的监听端口与其他软件有冲突,这是新手常犯的一个错误,Windows安装了IIS服务器的同时,又安装Apache服务器,二个服务器软件都监听TCP/IP协议的80端口,于是就有其中的 ...

  10. iOS 开发http post 文件的上传

    iOS开发网络篇—文件的上传 说明:文件上传使用的时POST请求,通常把要上传的数据保存在请求体中.本文介绍如何不借助第三方框架实现iOS开发中得文件上传. 由于过程较为复杂,因此本文只贴出部分关键代 ...