zoukankan      html  css  js  c++  java
  • web.xml中使用web前缀配置无法访问controller

    <web:context-param>
    <web:param-name>contextConfigLocation</web:param-name>
    <web:param-value>classpath:spring/applicationContext.xml</web:param-value>
    </web:context-param>

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

    <web:listener>
    <web:listener-class>org.springframework.web.util.IntrospectorCleanupListener</web:listener-class>
    </web:listener>


    <web:servlet>
    <web:servlet-name>springmvc</web:servlet-name>
    <web:servlet-class>org.springframework.web.servlet.DispatcherServlet</web:servlet-class>
    <web:init-param>
    <web:param-name>contextConfigLocation</web:param-name>
    <web:param-value>classpath:spring/springmvc.xml</web:param-value>
    </web:init-param>
    <web:load-on-startup>1</web:load-on-startup>
    </web:servlet>
    <web:servlet-mapping>
    <web:servlet-name>springmvc</web:servlet-name>
    <web:url-pattern>/</web:url-pattern>
    </web:servlet-mapping>
    使用上面这种配置是不行的。

    把web: 去掉

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>

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

    <listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>


    <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:spring/springmvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

  • 相关阅读:
    Flask websocket
    Vuex
    Web框架的原理
    node.js
    nginx负载均衡实验
    nginx与location语法详解
    git安装与初始化
    Flask 中的 Render Redirect HttpResponse
    jQuery快速入门
    前端知识总结--css用div画环形圆
  • 原文地址:https://www.cnblogs.com/lirenhe/p/9774462.html
Copyright © 2011-2022 走看看