No mapping found for HTTP request with URI [/prjName/contro] in DispatcherServlet with name 'spring'

问题描述:

先说下开发环境和jar包

用的是eclipse : Neon.1a Release , JAVA JDK1.8,JAR包:spring-xxxx.4.3 


spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util 
		http://www.springframework.org/schema/util/spring-util.xsd
		http://www.springframework.org/schema/mvc
        <span style="white-space:pre">	</span>http://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context.xsd">
	
	<mvc:annotation-driven />
	
	<context:component-scan base-package="com.tjs.trade.about.controller" />
	
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/views/" />
		<property name="suffix" value=".jsp" />
	</bean>
</beans>

web.xml部分代码

<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>classpath*:resources/spring/applicationContext.xml</param-value>
</context-param>
<servlet>
	<servlet-name>spring</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:resources/spring/spring-servlet.xml</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>spring</servlet-name>
	<url-pattern>/</url-pattern>
</servlet-mapping>

问题是:tomcat启动后通过url请求后台:

 org.springframework.web.servlet.PageNotFound noHandlerFound
警告: No mapping found for HTTP request with URI [/prjName/controllerxxx] in DispatcherServlet with name 'spring'


怀疑这里[/prjName/controllerxxx]把prjName也作为controller的requestMapping("")里的参数处理了,它提示没有找到这个映射,但为什么不是提示controllerxxx没找到呢,而把项目名也带上一起映射了,可能是web project setting里项目的命名空间配置成“/”了,这是一种可能


问题找到了,spring-servlet.xml和applicationContext.xml启动的时候根本就没加载

启动没报任何错,记得第一次配置好的时候,这两个文件的路径没设置对,后来设置对了,然后启动没被加载直接过了,我把这两个文件复制到外边,然后把项目里的删了再考进来,没问题了,对!就是备份一下源文件,删了再拷回来就没问题了,我只想说太坑了。。。。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值