zoukankan      html  css  js  c++  java
  • springmvc在web.xml中的配置

        <!-- SpringMVC核心分发器 -->
        <servlet>
            <servlet-name>dispatcherServlet</servlet-name>
            <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath*:/spring-mvc.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcherServlet</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>

    <!-- Spring配置 -->
    <!-- ====================================== -->
    <listener>
       <listenerclass>
         org.springframework.web.context.ContextLoaderListener
       </listener-class>
    </listener>
      
    
    <!-- 指定Spring Bean的配置文件所在目录。默认配置在WEB-INF目录下 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/applicationContext.xml</param-value>
    </context-param>
    
    
    
     
    spring-mvc.xml 文件

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"     
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"     
            xmlns:context="http://www.springframework.org/schema/context"     
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd   
           http://www.springframework.org/schema/context <a href="http://www.springframework.org/schema/context/spring-context-3.0.xsd">http://www.springframework.org/schema/context/spring-context-3.0.xsd</a>">
    
        <!-- 启用spring mvc 注解 -->
        <context:annotation-config />
    
        <!-- 设置使用注解的类所在的jar包 -->
        <context:component-scan base-package="controller"></context:component-scan>
    
        <!-- 完成请求和注解POJO的映射 -->
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
      
        <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/jsp/" p:suffix=".jsp" />
    
      
     <!-- 静态文件访问 -->
        <!-- <mvc:resources mapping="/resources/**" location="/resources/" /> -->
    
        <!-- 用于返回json格式 -->
        <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>application/x-www-form-urlencoded;charset=UTF-8</value>
                </list>
            </property>
        </bean>
     </beans> 

    ok,ok,ok,it is the springmvc of xml file...




  • 相关阅读:
    JsBridge踩坑之WebViewJavascriptBridge is undefined,找不到Bridge对象
    Android踩坑之couldn't find "libClingSDK.so"
    GDM, KDM, LightDM, SDDM的区别和安装配置
    安装完ubuntu需要做得事
    apt vs snap
    在shell下执行命令的方法
    Vimmer一套全语言支持的完美Vim配置——附Monaco字体
    Ubuntu gnome安装Monaco字体,FontForge module is probably not installed
    Ubuntu全方位美化,定制教程
    stm32--FatFs调试过程(SPIFlash)
  • 原文地址:https://www.cnblogs.com/huzi007/p/5765231.html
Copyright © 2011-2022 走看看