spring 3.0.5 入引<mvc:resources后解决静态资源的问题,可是URL访问请求确不能解析,原来的servlet控制器不起作用了,尝试了半天最后<mvc:annotation-driven/> 问题解决。
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
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/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- <mvc:resources mapping="/static/**" location="/"/> -->
<!-- <mvc:default-servlet-handler/> -->
<!-- <mvc:default-servlet-handler -->
<!-- default-servlet-name="default"/> -->
<mvc:resources mapping="/static/**" location="/WEB-INF/jsp/static/" />
<mvc:annotation-driven/>
<!-- 激活Spring注解方式:自动扫描,并注入bean -->
<context:component-scan base-package="org.xxx.blog.action" />
<!-- 配置视图解析 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- <mvc:resources mapping="/static/**" location="/static/" /> -->
</beans>
分享到:
相关推荐
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven /> <!-- 扫描Controller所在的包 --> <context:component-scan base-package="com.example.controller" /> <!-- 自定义拦截器配置 --> <mvc:interceptors> <bean class=...
<mvc:annotation-driven/> <!-- 资源处理 --> <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"/> <!-- 其他自定义配置... --> </beans> ``` 通过以上步骤,可以成功搭建一个基于...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp...
<mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:default-servlet-handler /> <aop:config proxy-target-class="true"/> <tx:annotation-driven ...
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> ...
<mvc:annotation-driven/> <!-- 数据源配置 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value=...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven/> <!-- 扫描Controller --> <context:component-scan base-package="cn.abc.controller"/> </beans> ``` ##### 5.2 配置web.xml 设置`context-param`和`ContextLoaderListener`以启动...
<mvc:annotation-driven /> <!-- 处理静态资源 --> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- 日志配置 --> <bean id="logbackConfigLocation" class="org.springframework.beans....
<mvc:annotation-driven/> <!-- 视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name=...
<mvc:annotation-driven /> <!-- 视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name=...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven/> </beans> ``` ##### 4. 数据库连接配置 在`src/main/resources`目录下创建`jdbc.properties`文件,配置数据库连接信息: ```properties jdbc.driverClassName=...