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. C语言之六大排序算法

    排序算法 1.直接插入排序 直接插入排序是将原始数据依次从已排好序的序列的最右侧比较起,若小于则向前插,一直插到合适的位置即可. 源代码如下: #include<stdio.h> void ...

  2. QPushButton跑进度条(使用QSS的不同修饰来实现,其实是伪进度条)

    主要用到qlineargradient,写以下CSS样式即可实现: background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, sto ...

  3. 工程脚本插件方案 - c集成Python基础篇(VC++嵌入Python)

    序: 为什么要集成脚本,怎么在工程中集成Python脚本. 在做比较大型的工程时,一般都会分核心层和业务层.核心层要求实现高效和稳定的基础功能,并提供调用接口供业务层调用的一种标准的框架划分.在实际中 ...

  4. 基于visual Studio2013解决C语言竞赛题之0403字符统计

      题目 解决代码及点评 这道题的目标是锻炼while循环,while循环的语法是 while(循环条件) { 循环体; } 每次进入循环体之前,先判断循环条件是否满足,如果不满足,执行序列就 ...

  5. ASP.NET 内置对象涉略

    一.ASP.NET中内置的常用对象的介绍 本文列举了ASP.NET 的八个内置对象,其中前五个是比较常用的. 1.Response Response 对象用于从服务器向用户发送输出的结果. Write ...

  6. Yii Framework2.0开发教程(2)使用表单Form

    第一步.接着教程(1).我们在controllers/ZhyoulunController.php中加入两处, 1) use app\models\EntryForm; 和 2) public fun ...

  7. AJAX同步与异步

    今天来大概说说AJAX中的同步与异步.其实,就我的理解,同步与异步的区别就是程序执行过程中是否有等待. 同步:意思就是js代码加载到当前的 AJAX时候,会等待AJAX代码执行完毕后再开始加载其他代码 ...

  8. Struts1的处理流程

    本文从收到一个请求开始讲述,忽略之前的filter等工作. 处理工作的主要承担者为RequestProcessor 1.处理请求的url. RequestProcessor.processPath(r ...

  9. 2、Zookeeper集群搭建、命令行Client操作

    zookeeper 集群最好是奇数台: 5台允许挂掉2台 4台只能允许挂掉1台 zjtest7-redis:/opt/zookeeper/bin# ./zkServer.sh status ZooKe ...

  10. 在 vb中 "end","unload me","exit sub" 之间的区别

    之前就想过这个问题,这么熟悉的几个东西居然对他们分析的不是很透彻. “End”  跟  “Unload  Me”  在敲程序 的时候经常敲到,“exit  sub”  更是熟悉,下面,解析: End  ...