<context:include-filter> 与 mvc:view-controller 的使用
来源:互联网 发布:网络机顶盒收费吗 编辑:程序博客网 时间:2024/06/16 05:46
1、重定向
<mvc:view-controller path="/" view-name="redirect:/admin/index"/>
即如果当前路径是/ 则重定向到/admin/index
2、view name
<mvc:view-controller path="/" view-name=admin/index"/>
如果当前路径是/ 则交给相应的视图解析器直接解析为视图
如
<bean id="defaultViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="2">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="contentType" value="text/html"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
则得到的视图时 /WEB-INF/jsp/admin/index.jsp
不想进controller,可以在spring-mvc.xml中配置静态访问路径
Xml代码
<!-- 访问静态资源文件 -->
<mvc:resources mapping="/images/**" location="/images/" cache-period="31556926"/>
像这样,jsp文件若放在静态路径/images下,可以直接访问,而不经过controller。
spring <context:component-scan>使用说明
在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有@Component @Controller@Service等这些注解的类,则把这些类注册为bean
注意:如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者。另外<context:annotation-config/>还提供了两个子标签
1. <context:include-filter> 只扫描controller包
<context:component-scan base-package="tv.huan.weisp.web .controller">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
2. <context:exclude-filter> 不扫描 controller包
<context:component-scan base-package="tv.huan.weisp.web ">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
- <context:include-filter> 与 mvc:view-controller 的使用
- context:exclude-filter 与 context:include-filter
- context:exclude-filter 与 context:include-filter
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方 在Spring MVC中的配置中一般会遇到这两个标签,作
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方 在Spring MVC中的配置中一般会遇到这两个标签,作为<
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- 【SpringMVC】<context:include-filter>和<context:exclude-filter>使用时要注意的地方
- spring mvc中mvc:view-controller的使用
- springmvc mvc:view-controller使用
- <mvc:view-controller />的用法
- .net MVC的controller与view的传值方式
- MVC中Controller与View之间的数据传递
- 1 Spring MVC View层与Controller层的衔接
- heatmap example
- mybatis中jdbctype的作用
- SSD的Matching Strategy
- Swift3.0中无父类的类用description打印地址
- android autolayout框架
- <context:include-filter> 与 mvc:view-controller 的使用
- 第十天H5进阶
- Kafka整理
- 雇员管理系统ssh之准备1
- IntelliJ Idea 2017 获取密钥
- OleDbDataAdapter 具体使用案例
- 人来到这个世界上,不就是在互相比拼,看谁能够承受得更多吗?
- PHP中获取文件扩展名的N种方法
- 进制转换的通用方法