lucifer_li6 2012-08-17 18:52
浏览 247
已采纳

初学SpringMVC

web.xml:
<?xml version="1.0" encoding="UTF-8"?>

SpringTest


contextConfigLocation
/WEB-INF/spring-servlet.xml


org.springframework.web.context.ContextLoaderListener


spring
org.springframework.web.servlet.DispatcherServlet
1


spring
*.do


index.html

spring-servlet.xml:

<?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">

  <mvc:annotation-driven />

 <context:component-scan base-package="com.spring.mvc" />

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/view/" p:suffix=".jsp" />

Constroller:

package com.spring.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class RestConstroller {

public RestConstroller() { }

 @RequestMapping(value = "/welcome", method = RequestMethod.GET)
 public String registPost() {

  return "welcome";

 }

}

报错:
2012-8-17 18:04:01 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/SpringTest/welcome.do] in DispatcherServlet with name 'spring'

按教程上面写的,试过几次就是有问题

  • 写回答

3条回答

  • jinnianshilongnian 2012-08-17 20:49
    关注

    你的这个配置 没问题啊!

    clean下服务器,重启试试,如果还是不行,把详细的log写出来、还有你的代码最好打个包发上来

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog