收到此错误:源服务器未找到目标资源的当前表示或不愿意透露该表示存在[重复]

问题描述 投票:0回答:1

运行项目“FirstServlet”后,单击“MyServlet Page”链接后出现错误。

这是我的文件结构

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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">
    <servlet>
        <servlet-name>hello</servlet-name>
        <servlet-class>MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>hello</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

index.html

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div>Click here, to go <a href= "hello"> MyServlet Page.</a></div>
    </body>
</html>
tomcat servlets
1个回答
-1
投票

在您的 href html 代码中,应删除等号和双引号之间的间隙,以便连接等号和双引号。

© www.soinside.com 2019 - 2024. All rights reserved.