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的更多相关文章

  1. SpringMvc环境搭建(配置文件)

    在上面的随笔里已经把搭建springmvc环境的基本需要的包都下下来了,拉下来就是写配置文件了. 下面左图是总的结构,右图是增加包 一.最开始当然是web.xml文件了,这是一个总的宏观配置 < ...

  2. SpringMVC环境搭建 配置文件_2

    applicationContext 命名空间: 引入命名空间,这样可以在代码中使用annotation xmlns="http://www.springframework.org/sche ...

  3. SpringMVC环境搭建和详解

    1.Spring容器和SpringMVC容器是父子容器 1.1 SpringMVC容器可以调用Spring容器中的所有内容 1.2 图示 2.SpringMVC环境搭建 1.导入jar包 2.在web ...

  4. springmvc环境搭建及实例

    一. 软件环境 eclipse-jee-mars-R-win32-x86_64 jdk1.7.0_79 apache-tomcat-7.0.52 spring-framework-3.2.0.RELE ...

  5. springmvc环境搭建以及常见问题解决

    1.新建maven工程 a)  打开eclipse,file->new->project->Maven->Maven Project b)  下一步 c)   选择创建的工程为 ...

  6. spring入门(五)【springMVC环境搭建】

    springMVC作为spring的一个WEB组件,是一个MVC的思想,减少了WEB开发的难度,现介绍springMVC环境的搭建,具体的原理放在后面介绍.用过框架的朋友都知道要在WEB项目中使用一个 ...

  7. SpringMVC 环境搭建

    SpringMVC 框架环境搭建操作步骤如下: 创建动态 Web 项目 配置 Tomcat 服务器 配置 SpringMVC 前端控制器 <?xml version="1.0" ...

  8. SpringMVC工作环境搭建 配置文件

    web.xml配置 在服务器端容器启动之前加载配置文件的顺序:context-param>listener>filter>servlet //容器配置application上下文的时 ...

  9. SpringMVC环境搭建

    Spring MVC为展现层提供的基于MVC设计理念的优秀Web框架,是目前最主流的MVC框架之一. Spring 3.0之后完全超越Struts2,称为最优秀的MVC框架.学完SpringMVC之后 ...

随机推荐

  1. C++ 虚函数,纯虚函数的一些问题

    #include <iostream> using namespace std; #define cendl cout << endl; class AA{//这是一个纯虚函数 ...

  2. 创建Maven web项目时 出现 web.xml is missing and <failOnMissingWebXml> is set to true错误 pox.xml编译错误

    今天创建一个maven项目 pom.xml出现如下错误: web.xml is missing and <failOnMissingWebXml> is set to true 这是因为你 ...

  3. 基于Bootstrap的JQuery TreeView树形控件,数据支持json字符串、list集合(MVC5)<二>

    上篇博客给大家介绍了基于Bootstrap的JQuery TreeView树形控件,数据支持json字符串.list集合(MVC5)<一>, 其中的两种方式都显得有些冗余.接着上篇博客继续 ...

  4. java数组引用

    public class Arriy { public static void main(String args[]){ int data[]=new int[3]; data[0]=10; data ...

  5. 安装Nginx的Dockerfile实例

    #################################################Dockerfile to build Nginx Installed Containers##Bas ...

  6. etl学习系列1——etl工具安装

    ETL(Extract-Transform-Load的缩写,即数据抽取.转换.装载的过程),对于企业或行业应用来说,我们经常会遇到各种数据的处理,转换,迁移,所以了解并掌握一种etl工具的使用,必不可 ...

  7. unity行为树制作AI简单例子(1)

    用行为树来制作AI是非常方便的,今天就给大家简单介绍一下行为树的强大之处. 所用插件 Behavior Designer v1.421 最开始 我使用过Rain插件,不过用过Behavior Desi ...

  8. Eclipse中将Java项目转换成Web项目的方法

    前言: 用Eclipse开发项目的时候,把一个Web项目导入到Eclipse里会变成了一个java工程,将无法在Tomcat中进行部署运行. 方法: 1.找到.project文件,找到里面的<n ...

  9. JVM内存模型和性能优化 转

    JVM内存模型和性能优化 JVM内存模型优点 内置基于内存的并发模型:      多线程机制 同步锁Synchronization 大量线程安全型库包支持 基于内存的并发机制,粒度灵活控制,灵活度高于 ...

  10. php mysql 一个查询优化的简单例子

    PHP+Mysql是一个最经常使用的黄金搭档,它们俩配合使用,能够发挥出最佳性能,当然,如果配合Apache使用,就更加Perfect了. 因此,需要做好对mysql的查询优化.下面通过一个简单的例子 ...