我搭建的老出错,而且我搭建的只能访问jsp,访问html不成功,完了css样式加载不出来,路径也没有错啊
配置贴出来看看,静态文件需要配置的,给你一个参考,既可以使用jsp,也可以使用beetl,还可以访问静态html
<?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"
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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<bean name="beetlConfig" class="org.beetl.ext.spring.BeetlGroupUtilConfiguration"
init-method="init">
<property name="configFileResource" value="beetl.properties" />
</bean>
<!-- Beetl视图解析器1 -->
<bean name="beetlViewResolver" class="org.beetl.ext.spring.BeetlSpringViewResolver">
<!-- 多视图解析器,需要设置viewNames和order -->
<property name="viewNames">
<list>
<value>/template/**</value>
</list>
</property>
<property name="suffix" value=".btl" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="order" value="0" />
<!-- 多GroupTemplate,需要指定使用的bean -->
<property name="config" ref="beetlConfig" />
</bean>
<!-- JSP视图解析器 -->
<bean name="JSPViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 注意JSP的这个视图解析器order必须在最后 -->
<property name="order" value="256" />
<!-- beetl配置不支持前缀,这不同于jsp 和 freemaker -->
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
<!--避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 -->
</list>
</property>
</bean>
<mvc:annotation-driven />
<!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd -->
<mvc:resources mapping="/i/**" location="/assets/i/" />
<mvc:resources mapping="/js/**" location="/assets/js/" />
<mvc:resources mapping="/fonts/**" location="/assets/fonts/" />
<mvc:resources mapping="/css/**" location="/assets/css/" />
<mvc:resources mapping="/html/**" location="/assets/html/" />
<!-- 拦截器 開發時暫不啟用-->
<!--
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<mvc:exclude-mapping path="/login" />
<bean class="com.extans.interceptor.UserSecurityInterceptor">
</bean>
</mvc:interceptor>
</mvc:interceptors>
-->
<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 默认编码 -->
<property name="defaultEncoding" value="utf-8" />
<!-- 文件大小最大值 -->
<property name="maxUploadSize" value="10485760000" />
<!-- 内存中的最大值 -->
<property name="maxInMemorySize" value="40960" />
</bean>
</beans>
可以参考下笔者写的:
http://blog.csdn.net/evankaka/article/details/49452201
http://blog.csdn.net/Evankaka/article/details/48784641
文章中有工程可以下载
http://blog.csdn.net/extraordinarylife/article/details/52701460 很详细 没学过都能看懂
http://blog.csdn.net/u013451048/article/details/52971906
看看这个