SpringMVC环境搭建 配置文件_3
springmvc-servlet.xml
引入命名空间,引入注解
命名空间:
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<context:annotation-config/>
注册并只将controller bean引入到springmvc容器中
<context:component-scan base-package="com.wtw">
<context:include-filter type="annotaion" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 处理静态资源的请求-->
<mvc:default-servlet-handler />
<!--
<mvc:annotation-driven /> 是一种简写形式,完全可以手动配置替代这种简写形式,简写形式可以让初学都快速应用默认配置方案。
<mvc:annotation-driven /> 会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,是spring MVC为@Controllers分发请求所必须的。
并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。-->
<mvc:annotation-driven/>
<!--静态资源的绑定-->
<mvc:resources location="/script/js/*" mapping="/js/**" />
<mvc:resources location="/style/images/*" mapping="/img/**" />
<mvc:resources location="/style/css/*" mapping="/css/**" />
<mvc:resources location="" mapping=""/>
<!-- 配置拦截器及拦截目标 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/stu/*" />
<mvc:exclude-mapping path="/login" />
<bean class="com.wtw.interceptor.LoginInterceptor">
</bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- 逻辑视图的视图解析器,将得到的逻辑视图添加前缀后缀获取最终的视图页面 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
id="internalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsp/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
<!-- 文件上传 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="2048000"></property>
<property name="defaultEncoding" value="UTF-8"></property>
</bean>
SpringMVC环境搭建 配置文件_3的更多相关文章
- SpringMvc环境搭建(配置文件)
在上面的随笔里已经把搭建springmvc环境的基本需要的包都下下来了,拉下来就是写配置文件了. 下面左图是总的结构,右图是增加包 一.最开始当然是web.xml文件了,这是一个总的宏观配置 < ...
- SpringMVC环境搭建 配置文件_2
applicationContext 命名空间: 引入命名空间,这样可以在代码中使用annotation xmlns="http://www.springframework.org/sche ...
- SpringMVC环境搭建和详解
1.Spring容器和SpringMVC容器是父子容器 1.1 SpringMVC容器可以调用Spring容器中的所有内容 1.2 图示 2.SpringMVC环境搭建 1.导入jar包 2.在web ...
- springmvc环境搭建及实例
一. 软件环境 eclipse-jee-mars-R-win32-x86_64 jdk1.7.0_79 apache-tomcat-7.0.52 spring-framework-3.2.0.RELE ...
- springmvc环境搭建以及常见问题解决
1.新建maven工程 a) 打开eclipse,file->new->project->Maven->Maven Project b) 下一步 c) 选择创建的工程为 ...
- spring入门(五)【springMVC环境搭建】
springMVC作为spring的一个WEB组件,是一个MVC的思想,减少了WEB开发的难度,现介绍springMVC环境的搭建,具体的原理放在后面介绍.用过框架的朋友都知道要在WEB项目中使用一个 ...
- SpringMVC 环境搭建
SpringMVC 框架环境搭建操作步骤如下: 创建动态 Web 项目 配置 Tomcat 服务器 配置 SpringMVC 前端控制器 <?xml version="1.0" ...
- SpringMVC工作环境搭建 配置文件
web.xml配置 在服务器端容器启动之前加载配置文件的顺序:context-param>listener>filter>servlet //容器配置application上下文的时 ...
- SpringMVC环境搭建
Spring MVC为展现层提供的基于MVC设计理念的优秀Web框架,是目前最主流的MVC框架之一. Spring 3.0之后完全超越Struts2,称为最优秀的MVC框架.学完SpringMVC之后 ...
随机推荐
- Linux下的五个查找命令:grep、find、locate、whereis、which
原文转自 http://www.cnblogs.com/wanqieddy/archive/2011/07/15/2107071.html 1.grep grep(General Regular Ex ...
- winfrom 限制文本框小数点后两位
private void numWeight_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsNumber(e.KeyChar) | ...
- 自学 PHP,如何不走弯路?
1.一本好书至关重要.如果这本书的知识非常深入,那么还是不要看了.对初学者来说只能是打击.因为很多东西都看不懂.一本知识较为浅显,并且说明非常详细,但是能让你上手的基础知识又非常完善的书籍就非常好.( ...
- iOS 一个app跳转另一个app并实现通信(如A跳到B并打开B中指定页面)
功能实现:A跳到B并打开B中指定页面 步骤: 1.首先创建两个项目(项目A,项目B),在项目B中的info.plist文件中添加URL Types,如下图所示:其中URL idenifier是项目B的 ...
- Redhat6.5使用centos yum源
新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统.提示:This system is not registered to Red Hat Subscription Ma ...
- ayase系列
[冒个泡]技能视觉效果の自定义 by ayase [11-09 V2.4]任务数量转换属性点的lua脚本 [335]瞎倒腾的item.dbc生成工具..
- Bridge.NET
块作用域闭包问题 结果正确:1 容易引入JSB:1 public class Program { static List<Action> createActions() { List< ...
- 20160113 js中选择多个check一块删除
js中<script type="text/javascript"> $(document).ready(function (e) { $("#Button2 ...
- 常用软件:Bugzilla的搭建(转)
1.安装依赖包yum -y install php perl httpd mod_ssl mysql-server mysql-devel mysql php-mysql gcc mod_perl-d ...
- fMRI数据分析处理原理及方法(转载)
原文地址:http://www.cnblogs.com/minks/p/4889497.html 近年来,血氧水平依赖性磁共振脑功能成像(Blood oxygenation level-depende ...