有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java哪里是Servlet映射中的无效内容

为无效的url模式获取以下erorr。试图完全按照Telusko的教程进行操作https://www.youtube.com/watch?v=wty6OROO__8&list=PLsyeobzWxl7pUPF2xjjJiG4BKC9x_GY46&index=6

我表单中的action属性设置为“add”,我尝试过使用或不使用正斜杠,但都没有成功。请帮忙。多谢各位

cvc-complex-type.2.4.a: Invalid content was found starting with element 'servlet-mapping'. One of '{"http://
 xmlns.jcp.org/xml/ns/javaee":url-pattern}' is expected.

网络。xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

<servlet>
    <servlet-name>abc</servlet-name>
    <servlet-class>com.centeno.AddServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>abc</servlet-name>
    <servlet-mapping>/add</servlet-mapping>
</servlet-mapping>

</web-app>

共 (1) 个答案

  1. # 1 楼答案

    尝试url模式,而不是servlet映射内部标记servlet映射

        <servlet-mapping>
            <servlet-name></servlet-name>
            <url-pattern></url-pattern>
        </servlet-mapping>