0

I don't know how those error occured,the project goes no any problem just now.

I remember I renamed the index.jsp and create a new RestController.

The error say "Element param-serviceName is not allowed here".

Here are some images show the errors

web.xml:

web.xml

applicationContext.xml:

applicationContext.xml

and the code of the web.xml as follows,others xml files like the web.xml

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">

<!--配置Spring核心监听器-->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!--指定Spring的配置文件-->
<context-param>
    <param-serviceName>contextConfigLocation</param-serviceName>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<!--Spring MVC的前端控制器-->
<servlet>
    <servlet-serviceName>springmvc</servlet-serviceName>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-serviceName>contextConfigLocation</param-serviceName>
        <param-value>/WEB-INF/springmvc-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <multipart-config>
        <!--临时文件的目录-->
        <location>/tmp/</location>
        <!-- 上传文件最大2M -->
        <max-file-size>2097152</max-file-size>
        <!-- 上传文件整个请求不超过4M -->
        <max-request-size>4194304</max-request-size>
    </multipart-config>
</servlet>
<servlet-mapping>
    <servlet-serviceName>springmvc</servlet-serviceName>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<!--编码过滤器-->
<filter>
    <filter-serviceName>characterEncodingFilter</filter-serviceName>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-serviceName>encoding</param-serviceName>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-serviceName>forceEncoding</param-serviceName>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-serviceName>characterEncodingFilter</filter-serviceName>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!--session有效时间-->
<session-config>
    <session-timeout>30</session-timeout>
</session-config>

curious
  • 1,504
  • 5
  • 18
  • 32
widiot
  • 3
  • 2

1 Answers1

0

Consider this my mistake to not be able to help OP properly

The issue in your web.xml is, it is using wrong tags.

update your web.xml to this and then try.

<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">

    <!--配置Spring核心监听器-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--指定Spring的配置文件-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <!--Spring MVC的前端控制器-->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/springmvc-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <multipart-config>
            <!--临时文件的目录-->
            <location>/tmp/</location>
            <!-- 上传文件最大2M -->
            <max-file-size>2097152</max-file-size>
            <!-- 上传文件整个请求不超过4M -->
            <max-request-size>4194304</max-request-size>
        </multipart-config>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</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>

    <!--session有效时间-->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
</web-app>
Acewin
  • 1,657
  • 4
  • 17
  • 36
  • I finally know what happened, because I used the IDEA's rename to rename a property named "name" to "serviceName",the IDEA actually rename all the "name",including the XML.I want to curse. – widiot Aug 23 '17 at 03:55
  • Thank you very much – widiot Aug 23 '17 at 03:59