您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Spring的MVC配置

2024/8/27 22:23:45发布18次查看
这次给大家带来spring的mvc配置,spring的mvc配置注意事项有哪些,下面就是实战案例,一起来看一下。
<?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:util="http://www.springframework.org/schema/util" 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/util http://www.springframework.org/schema/util/spring-util.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" > <!-- 默认的注解映射的支持 --> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="com.alibaba.fastjson.support.spring.fastjsonhttpmessageconverter"> <property name="supportedmediatypes" value="application/json"/> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 如果当前请求为“/”时,则转发到“/index” --> <mvc:view-controller path="/" view-name="forward:/index" /> <!-- 静态资源映射 --> <mvc:resources mapping="js/**" location="/static/js/" /> <mvc:resources mapping="css/**" location="/static/css/" /> <mvc:resources mapping="fonts/**" location="/static/fonts/" /> <mvc:resources mapping="plugins/**" location="/static/plugins/" /> <mvc:resources mapping="images/**" location="/static/images/" /> <!-- 当上面要访问的静态资源不包括在上面的配置中时,则根据此配置来访问 --> <mvc:default-servlet-handler/> <!-- 开启controller注解支持 --> <!-- use-default-filters="false" 只扫描指定的注解 --> <context:component-scan base-package="com.troyforever.example.mvc.controller" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.controller"/> </context:component-scan> <!-- 视图解析器 --> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="viewclass" value="org.springframework.web.servlet.view.jstlview"/> <property name="contenttype" value="text/html"/> <property name="prefix" value="/web-inf/views/"/> <property name="suffix" value=".jsp"/> </bean></beans>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
相关阅读:
hibernate的映射文件详解
使用maven配置文件pom.xml
以上就是spring的mvc配置的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product