gpt4 book ai didi

java - 无法在 apache tomcat 上运行 servlet。它说,请求的资源不可用

转载 作者:行者123 更新时间:2023-11-28 23:55:52 25 4
gpt4 key购买 nike

<分区>

亲爱的 stackoverflow 成员(member),

到目前为止我已经做了什么:

  1. 我从我的 eclipse 创建 apache tomcat 服务器

  2. 我也成功地在 .html 文件中运行简单的“hello world”

问题是当我运行一个 servlet 时它显示错误

HTTP Status 404 - /SimpleServletProject/SimpleServlet

type Status report

message /SimpleServletProject/SimpleServlet

description The requested resource is not available.


Apache Tomcat/7.0.42

下面是我的servlet

package com.bukuwow.azura;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class SimpleServlet
*/
@WebServlet(description = "a simple servlet", urlPatterns = { "/SimpleServlet" })
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Hello from servlet");
}

}

这是我的项目结构

SimpleServletProject
-------.settings
------------.jsdtscope
------------org.eclipse.jdt.core.prefs
------------org.eclipse.wst.common.component
------------org.eclipse.wst.common.project.facet.core.xml
------------org.eclipse.wst.jsdt.ui.superType.container
------------org.eclipse.wst.jsdt.ui.superType.name
-------build
------------classes
-------src
------------com
-----------------bukuwow
----------------------azura
---------------------------SimpleServlet.java
-------WebContent
------------META-INF
-----------------MANIFEST.MF
------------WEB-INF
-----------------lib
-----------------web.xml
------------index.html
-------.classpath
-------.project

日志文件看起来正常

Nov 05, 2014 10:51:17 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\Program Files (x86)\Seagate Software\NOTES\;C:\Program Files (x86)\Seagate Software\NOTES\DATA\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files\MATLAB\R2013a\runtime\win64;C:\Program Files\MATLAB\R2013a\bin;C:\Program Files\Calibre2\;C:\xampp\mysql\bin;C:\Android\apache-ant-1.9.2-bin\apache-ant-1.9.2\bin;C:\Program Files (x86)\Rational\common;C:\Program Files (x86)\Git\cmd;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Program Files (x86)\MacType;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Users\azura\apache-maven-3.2.2\bin;C:\Ruby200\bin;.
Nov 05, 2014 10:51:17 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SimpleServletProject' did not find a matching property.
Nov 05, 2014 10:51:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 05, 2014 10:51:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 05, 2014 10:51:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1162 ms
Nov 05, 2014 10:51:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 05, 2014 10:51:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Nov 05, 2014 10:51:19 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [384] milliseconds.
Nov 05, 2014 10:51:19 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\xampp\tomcat\conf\Catalina\localhost\website.xml
Nov 05, 2014 10:51:19 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\xampp\tomcat\webapps\my-webapp.war
Nov 05, 2014 10:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\xampp\tomcat\webapps\docs
Nov 05, 2014 10:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\xampp\tomcat\webapps\examples
Nov 05, 2014 10:51:19 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Nov 05, 2014 10:51:19 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Nov 05, 2014 10:51:19 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@622f1be6')
Nov 05, 2014 10:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\xampp\tomcat\webapps\host-manager
Nov 05, 2014 10:51:20 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\xampp\tomcat\webapps\manager
Nov 05, 2014 10:51:20 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\xampp\tomcat\webapps\ROOT
Nov 05, 2014 10:51:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 05, 2014 10:51:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 05, 2014 10:51:20 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2092 ms

这里是我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SimpleServletProject</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com