[size=16px]求大佬解惑,maven配置的spring+spingmvc。但是web.xml没有contextloaderlistener标签,只好手动配置,项目运行无问题,但是很麻烦
下面是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:caonima.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>/WEB-INF/view/testporject/jingtaipage/qiantai/index.jsp</welcome-file>
</welcome-file-list></web-app>

解决方案 »

  1.   

    大哥你说的是这个吗:
    <!--Spring上下文监听器-->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
      

  2.   

    嗯,对,可以直接alt+/打出来,不用手敲
      

  3.   

    嗯,对,可以直接alt+/打出来,不用手敲所以这问题解决了么?
      

  4.   

    嗯,对,可以直接alt+/打出来,不用手敲所以这问题解决了么?
    没有,不知道怎么弄
      

  5.   

    同问,好郁闷,不知知道是不是spring版本的问题
      

  6.   

    不知道,到最后也没有解决.现在用springboot了,不需要xml配置了
      

  7.   

    对,怎么弄出来的?现在都换idea了....用springboot都不用陪xml了
      

  8.   

    你在eclipse中安装Spring插件,就会有contextloaderlistener标签了,哈哈哈哈哈,现在CSDN好麻烦,不能即时聊天沟通,唉
      

  9.   

    这样哈,后来就没有鼓捣过了,完全手写也算是个锻炼哈哈。可以试试idea,好用的一b