开发者社区> 问答> 正文

springmvc 加载资源报404?报错

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:context="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-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
       
    <context:component-scan base-package="com.gttown.jui.controller" />

    <bean
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <list>
                <bean
                    class="org.springframework.http.converter.StringHttpMessageConverter">
                    <property name="supportedMediaTypes">
                        <list>
                            <value>text/plain;charset=UTF-8</value>
                        </list>
                    </property>
                </bean>
            </list>
        </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">
            
    </bean>

    <!-- <bean id="freemarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath"> <value>/WEB-INF/freemarker/</value>
        </property> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">1</prop>
        <prop key="defaultEncoding">UTF-8</prop> <prop key="classic_compatible">true</prop>
        <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HHSs</prop>
        <prop key="number_format">#</prop> </props> </property> </bean> <bean id="viewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="cache" value="true"/> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
        <property name="suffix" value=".ftl"/> <property name="exposeRequestAttributes"
        value="true"/> <property name="exposeSessionAttributes" value="true"/> <property
        name="exposeSpringMacroHelpers" value="true"/> <property name="allowSessionOverride"
        value="true"/> <property name="contentType" value="text/html;charset=gbk"/>
        <property name="requestContextAttribute" value="rc"/> </bean> -->
        
    <mvc:resources mapping="/styles/**" location="/styles/" cache-period="31536000"/>
</beans>




访问:

http://localhost:8080/management/user/select.dadao

报错:

PageNotFound - No mapping found for HTTP request with URI [/management/user/select.dadao] in DispatcherServlet with name 'dispatcherServlet'

展开
收起
爱吃鱼的程序员 2020-06-22 13:56:27 412 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    加上<mvc:annotation-driven/>

    话说你用插入代码的方式贴出来,这看着多累啊

    回复 @Kings__:其实这句话就是替你注册了几个必备和常用的bean,不加的话就需要自己手动一个个配置注册一下。我看你这里没有注册DefaultAnnotationHandlerMapping,所以会映射不到。当然还是用这一行比较简单是的,我后我加上这句就好了,不是web.xml的请求过滤的问题web.xml如何配置?没见过.dadao的结束符
    2020-06-22 13:56:44
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载