Howard_14 2016-03-08 14:25 采纳率: 0%
浏览 1381
已采纳

请教下关于springmvc简单例子出错问题

警告: No mapping found for HTTP request with URI [/springmvc4/test1/helloworld] in DispatcherServlet with name 'springmvc'
运行后一直报错。
我贴下代码 各位帮我看下
web配置:
<?xml version="1.0" encoding="UTF-8"?>

springMVC1

index.html
index.htm
index.jsp
default.html
default.htm
default.jsp

spring-servlet.xml配置

springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath*:config/spring-servlet.xml

1


springmvc
/


<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

 <bean name="/test1/helloworld" class="com.web.controller.HelloWorldController" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/"></property>
    <property name="suffix" value=".jsp"></property>
</bean>
 com.web.controller下的类:

package com.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class HelloWorldController implements Controller{
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
System.out.println("aasdadasd");

    return new ModelAndView("/welcome");
}

}


  • 写回答

4条回答

  • tony4geek 2016-03-09 01:47
    关注

    你 /springmvc4/test1/helloworld
    这个对应的url 找不到你的controller 中的方法 ,看看是否扫描到相应的controller

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题