SpringMVC工作环境搭建 配置文件

web.xml配置

在服务器端容器启动之前加载配置文件的顺序:context-param>listener>filter>servlet

//容器配置application上下文的时候加载的文件

//这是spring容器的配置文件

<context-param>

  <param-name>contextConfigLocation</param-name>

  <param-value>classpath:applicationContext*.xml</param-value>

</context-param>

//springmvc在web容器中的启动类

<listener>

  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

//注册Springmvc中DispatcherServlet到web容器中

<servlet>

  <servlet-name>springmvc</servlet-name>

  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

  //初始化时使用的参数

  <init-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>classpath:springmvc-servlet.xml</param-value>

  </init-param>

</servlet>

<servlet-mapping>

  <servlet-name>springmvc</servlet-name>

  <url-patten>/</url-patten>

</servlet-mapping>

//解决中文乱码问题

<filter>

  <filter-name>SetCharacterEncoding</filter-name>

  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

  <init-param>

    <param-name>encoding</param-name>

    <param-class>UTF-8</param-class>

  </init-param>

</filter>

<filter-mapping>

  <filter-name>SetCharacterEncoding</filter-name>

  <url-patten>/</url-patten>

</filter-mapping>

上一篇:apache服务器安装以及使用passenger插件部署rails应用


下一篇:[转] iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)