zoukankan      html  css  js  c++  java
  • web.xml+spring mvc基本配置

    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">
      <display-name>IT-middleware</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
      
      <servlet>
          <servlet-name>dispatcher</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/classes/spring-web-config.xml</param-value>
          </init-param>
          <load-on-startup>1</load-on-startup>
      </servlet>
      
      <servlet-mapping>
          <servlet-name>dispatcher</servlet-name>
          <url-pattern>/</url-pattern>
      </servlet-mapping>
      
      <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      
      <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
      </context-param>
      
      
    </web-app>    

    applicationContext.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        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.xsd ">
    
    
    
    </beans>

    spring-web-config.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        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/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd ">
    
        <context:component-scan base-package="wostore.it.middleware.controller" />
    
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
            <property name="prefix" value="/WEB-INF/views/" />
            <property name="suffix" value=".html" />
        </bean>
    
        <mvc:resources mapping="/resources/**" location="/resources/" />
    
        <mvc:annotation-driven />
    
         <mvc:default-servlet-handler/>
     
    </beans>
  • 相关阅读:
    REAL6410、OK6410、TE6410 的区别
    在裸奔2440时候遇到的GPIO郁闷问题(作者gooogleman)
    Jlink V8 48 RMB,力特USB转串口线 35 RMB 甩了!所剩不多,先到先得。
    一个机械专业小混混(gooogleman)学习嵌入式ARM的真实经历
    如何给自己淘宝的宝贝做google广告?
    程序员开网店的一些经验分享
    【有奖辩论】工程师和销售创业谁更有优势?
    关于高端ARM处理器选型的一些个人看法(作者:gooogleman)
    要搬家了,准备甩掉剩下的十多个源动力笔记本包,运动休闲包!
    推荐一款高性价比android /wince/Linux ARM11 S3C6410 开发板
  • 原文地址:https://www.cnblogs.com/silva/p/7160613.html
Copyright © 2011-2022 走看看