您的位置:首页 > 编程语言 > Java开发

【请教】org.springframework.web.servlet.PageNotFound - No mapping found for HTTP req

2017-01-02 17:53 567 查看
org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/school5/newsInput.html] in DispatcherServlet with name 'b505'

**************************************************************************************************************************************
项目名:school5
**************************************************************************************************************************************
web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>school5</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
         classpath:applicationContext.xml
    </param-value>
  </context-param>
  <listener>
    <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
  </listener>
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>school5</param-value>
  </context-param>
  <servlet>
    <servlet-name>b505</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/b505-servlet.xml</param-value>
</init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>b505</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>openSession</filter-name>
    <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>openSession</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/classes/log4j.properties</param-value>
  </context-param>
  <context-param>
    <param-name>log4jRefreshInterval</param-name>
    <param-value>60000</param-value>
  </context-param>
  <listener>
    <listener-class>  
       org.springframework.web.util.Log4jConfigListener   
    </listener-class>
  </listener>
</web-app>
**************************************************************************************************************************************
b505-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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-3.1.xsd
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!-- 开启controller注解支持 -->
    <context:component-scan base-package="com.b505.web">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    
    <mvc:default-servlet-handler/>
     
    <mvc:annotation-driven >
     <mvc:message-converters>   
            <bean class="org.springframework.http.converter.StringHttpMessageConverter" >   
               <property name="supportedMediaTypes">  
<list>  
                    <value>application/json;charset=UTF-8</value> 
                    <value>text/html;charset=UTF-8</value>
                    </list>  

             </property> 

              </bean>
       </mvc:message-converters>  
</mvc:annotation-driven>
<!-- 上传图片和文件 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="104857600" />
    <property name="maxInMemorySize" value="4096" />
    <property name="defaultEncoding" value="UTF-8"></property>
</bean>
 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView" 
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />


  <!-- 声明DispatcherServlet不要拦截下面声明的目录   --> 
 <mvc:resources location="/js/" mapping="/js/**" />
 <mvc:resources location="/newsimg/" mapping="/newsimg/**"/>
 <mvc:resources location="/images/" mapping="/images/**"/>
 <mvc:resources location="/css/" mapping="/css/**"/>
 <mvc:resources location="js/themes/default/" mapping="js/themes/default/**"/>
</beans>
**************************************************************************************************************************************
尝试了:重新装MyEclipse,重新装Tomcat。在其他网站上查了很多,照着做都没有成功。
注:项目在另一台电脑上可以正常运行,在我的电脑上就不行了。又将项目移到服务器机子上也不行,现在我们的项目只能在一台机子上正常运行,好奇怪。
求教。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐