weixin_45249401
我敢扶老奶奶
采纳率100%
2021-04-13 16:04 阅读 167
已采纳

报错[http-nio-8080-exec-6]

我新添加了一个billcontroller后发现好像mvc无法识别报错,其他页面访问正常,百度了很多,注解和web配置都是没错的呀,新添加的这个注解什么的都加了,没有问题
查询数据库也可查出来,真得不知道是哪里有问题,在线等。。。。
具体错误:点订单管理报错404.其他功能正常

控制台报错:

报错


 

controller层

web.xml
 

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <!--乱码过滤器-->
  <filter>
    <filter-name>encode</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>
  </filter>
  <filter-mapping>
    <filter-name>encode</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!--MVC配置文件-->
  <servlet>
    <servlet-name>mvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring-*.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>mvc</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

spring-mvc.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:content="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.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.xsd">
    <content:component-scan base-package="cn.smbms"/>
    <!--转换器 解决返回对象时候 乱码 和 日期样式-->
    <!--<bean class="org.springframework.context.support.ConversionServiceFactoryBean" id="conversionService2">
        <property name="converters">
            <bean class="cn.smbms.converts.StringToDateConvert" id="stringToDateConvert"/>
        </property>
    </bean>-->
    <!--conversion-service=""-->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <!--配置消息转换器-->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>application/json;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
            <!--时间戳-->
            <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"
                  id="fastJsonHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>application/json;charset=UTF-8</value>
                        <value>text/html;charset=UTF-8</value>
                    </list>
                </property>
                <property name="features">
                    <list>
                        <value>WriteDateUseDateFormat</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean" id="bean">
        <property name="favorParameter" value="true"/>
        <property name="mediaTypes">
            <props>
                <prop key="html">text/html;charset=UTF-8</prop>
                <prop key="json">application/json;charset=UTF-8</prop>
                <prop key="xml">application/xml;charset=UTF-8</prop>
            </props>
        </property>
    </bean>
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver" id="negotiatingViewResolver">
        <property name="contentNegotiationManager" ref="bean"/>
        <property name="viewResolvers">
            <list>
                <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="prefix" value="/WEB-INF/jsp/"/>
                    <property name="suffix" value=".jsp"/>
                </bean>
            </list>
        </property>
    </bean>
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="viewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <mvc:resources mapping="/css/**" location="/css/"/>
    <mvc:resources mapping="/images/**" location="/images/"/>
    <mvc:resources mapping="/js/**" location="/js/"/>
    <mvc:resources mapping="/calendar/**" location="/calendar/"/>
    <!--全局异常处理-->
    <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="exceptionMappings">
            <props>
                <prop key="java.lang.RuntimeException">error</prop>
            </props>
        </property>
    </bean>
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="5000000"/>
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>
    <!--拦截器-->
    <mvc:interceptors>
        <mvc:interceptor>
            <!--拦截的请求-->
            <mvc:mapping path="/**"/>
            <!--排除的请求-->
            <mvc:exclude-mapping path="/"/>
            <mvc:exclude-mapping path="/login.do"/>
            <mvc:exclude-mapping path="/images/**"/>
            <mvc:exclude-mapping path="/js/**"/>
            <mvc:exclude-mapping path="/css/**"/>
            <mvc:exclude-mapping path="/calendar/**"/>

            <bean class="cn.smbms.intercept.Sysintercept" id="sysintercept"/>
        </mvc:interceptor>
    </mvc:interceptors>
    
</beans>


 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • 已采纳
    software7503 CSDN专家-赖老师(软件之家) 2021-04-13 16:34

    相对路径的问题,请采纳,谢谢!

    点赞 评论 复制链接分享
  • software7503 CSDN专家-赖老师(软件之家) 2021-04-13 16:09

    404报错是你的路径写错了,检查一下,注意区分大小写。

    点赞 评论 复制链接分享
  • weixin_45249401 我敢扶老奶奶 2021-04-13 16:14

    前台代码

     <li><a href="${pageContext.request.contextPath }/getBillList">订单管理</a></li>
    点赞 评论 复制链接分享
  • weixin_45249401 我敢扶老奶奶 2021-04-13 17:07

     return "forward:/billlist";报错,直接 return "/billlist";就可以进去,原来是下面少写了一个这个,谢谢大家。
    已经解决了

     @RequestMapping("/billlist")
        public String billlist() {
            return "billlist";
        }
    点赞 评论 复制链接分享
  • QA_Assistant 有问必答小助手 2021-04-13 18:57

    您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    点赞 评论 复制链接分享
  • QA_Assistant 有问必答小助手 2021-04-15 15:38

    非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

    速戳参与调研>>>https://t.csdnimg.cn/Kf0y

    点赞 评论 复制链接分享

相关推荐