说明 源服务器未找到目标资源的当前表示或不愿公开存在该表示
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
package com.luv3code.testdb;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
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 TestDBServlet
*/
@WebServlet("/TestDbServlet")
public class TestDBServlet 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 {
// TODO Auto-generated method stub
String user="springstudent";
String pass="springstudent";
String jdbcUrl= "jdbc:mysql://localhost:3306/web_customer_tracker?useSSL&serverTimezome=UTC";
String driver= "com.mysql.cj.jdbc.Driver";
try {
PrintWriter out=response.getWriter();
out.println("Connect to Database: " +jdbcUrl);
Class.forName(driver);
Connection myConn= DriverManager.getConnection(jdbcUrl, user, pass);
out.println("suceess");
}catch(Exception exc) {
exc.printStackTrace();
throw new ServletException(exc);
}
response.getWriter().append("Served at: ").append(request.getContextPath());
}
}
我创建了一个连接spring学生:与用户spring学生。除了在我的 workbench.
上用 table 创建一个数据库
我想在我的数据库上连接我的 eclipse 项目。所以我编写代码并添加一个库。
我的步数:
下载apachetomcat
创建网络动态项目。创建一个servlet 添加库
我的-sql-8.0.12
Java编译器,Java构建路径,Project Facest版本相同
我尝试 运行 进行以上两项设置:服务器右键单击
优先级:工作区元数据服务器右键单击优先级:
本地
删除并添加服务器(Window->Show Servers...) 检查项目
facets->运行点击 apache 的时间清理项目清理服务器
删除并再次导入项目。
控制台:
Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
version name: Apache Tomcat/9.0.35 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
built: May 5 2020 20:36:20 UTC Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
version number: 9.0.35.0 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name:
Windows 10 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: OS
Version: 10.0 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO:
Architecture: amd64 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home:
C:\Program Files\Java\jdk1.8.0_251\jre Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: JVM
Version: 1.8.0_251-b08 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: JVM
Vendor: Oracle Corporation Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO:
CATALINA_BASE:
C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1
Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO:
CATALINA_HOME: C:\Program Files\Apache Software
Foundation\Tomcat 9.0 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument:
-Dcatalina.base=C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1
Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Dcatalina.home=C:\Program Files\Apache Software
Foundation\Tomcat 9.0 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument:
-Dwtp.deploy=C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software
Foundation\Tomcat 9.0\endorsed Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Dfile.encoding=Cp1253 Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO:
Loaded Apache Tomcat Native library [1.2.24] using APR version
[1.7.0]. Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: APR
capabilities: IPv6 [true], sendfile [true], accept filters [false],
random [true]. Ιουν 14, 2020 1:57:58 ΠΜ
org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO:
APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.core.AprLifecycleListener
initializeSSL INFO: OpenSSL successfully initialized [OpenSSL 1.1.1g
21 Apr 2020] Ιουν 14, 2020 1:57:59 ΠΜ
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["http-nio-8081"] Ιουν 14, 2020 1:58:00 ΠΜ
org.apache.catalina.startup.Catalina load INFO: Server initialization
in [2,379] milliseconds Ιουν 14, 2020 1:58:00 ΠΜ
org.apache.catalina.core.StandardService startInternal INFO: Starting
service [Catalina] Ιουν 14, 2020 1:58:00 ΠΜ
org.apache.catalina.core.StandardEngine startInternal INFO: Starting
Servlet engine: [Apache Tomcat/9.0.35] Ιουν 14, 2020 1:58:02 ΠΜ
org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR
was scanned for TLDs yet contained no TLDs. Enable debug logging for
this logger for a complete list of JARs that were scanned but no TLDs
were found in them. Skipping unneeded JARs during scanning can improve
startup time and JSP compilation time. Ιουν 14, 2020 1:58:03 ΠΜ
org.apache.coyote.AbstractProtocol start INFO: Starting
ProtocolHandler ["http-nio-8081"] Ιουν 14, 2020 1:58:03 ΠΜ
org.apache.catalina.startup.Catalina start INFO: Server startup in
[2,449] milliseconds
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/web-customer-tracker/] is not
available
Description The origin server did not find a current representation
for the target resource or is not willing to disclose that one exists.
我有两台电脑,第一台运行程序如果改变
@WebServlet("/") 我无法解释为什么。
在这里它没有 运行.
我还重新安装了 eclipse 和 tomcat。
日蚀 2019
阿帕奇 9
java 版本“1.8.0_251”
Java(TM) SE 运行时环境(build 1.8.0_251-b08)
Java HotSpot(TM) 64 位服务器 VM(内部版本 25.251-b08,混合模式)
有人可以帮助我吗?
只需右键单击您的 servlet 并选择 Run As > Run on Server
。
package com.luv3code.testdb;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
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 TestDBServlet
*/
@WebServlet("/TestDbServlet")
public class TestDBServlet 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 {
// TODO Auto-generated method stub
String user="springstudent";
String pass="springstudent";
String jdbcUrl= "jdbc:mysql://localhost:3306/web_customer_tracker?useSSL&serverTimezome=UTC";
String driver= "com.mysql.cj.jdbc.Driver";
try {
PrintWriter out=response.getWriter();
out.println("Connect to Database: " +jdbcUrl);
Class.forName(driver);
Connection myConn= DriverManager.getConnection(jdbcUrl, user, pass);
out.println("suceess");
}catch(Exception exc) {
exc.printStackTrace();
throw new ServletException(exc);
}
response.getWriter().append("Served at: ").append(request.getContextPath());
}
}
我创建了一个连接spring学生:与用户spring学生。除了在我的 workbench.
上用 table 创建一个数据库我想在我的数据库上连接我的 eclipse 项目。所以我编写代码并添加一个库。
我的步数:
下载apachetomcat
创建网络动态项目。创建一个servlet 添加库 我的-sql-8.0.12
Java编译器,Java构建路径,Project Facest版本相同
我尝试 运行 进行以上两项设置:服务器右键单击 优先级:工作区元数据服务器右键单击优先级: 本地
删除并添加服务器(Window->Show Servers...) 检查项目 facets->运行点击 apache 的时间清理项目清理服务器
删除并再次导入项目。
控制台:
Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Server version name: Apache Tomcat/9.0.35 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: May 5 2020 20:36:20 UTC Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Server version number: 9.0.35.0 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name:
Windows 10 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 10.0 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Program Files\Java\jdk1.8.0_251\jre Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.8.0_251-b08 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE:
C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=C:\Users\User\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 9.0\endorsed Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=Cp1253 Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: Loaded Apache Tomcat Native library [1.2.24] using APR version [1.7.0]. Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] Ιουν 14, 2020 1:57:58 ΠΜ org.apache.catalina.core.AprLifecycleListener initializeSSL INFO: OpenSSL successfully initialized [OpenSSL 1.1.1g 21 Apr 2020] Ιουν 14, 2020 1:57:59 ΠΜ org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8081"] Ιουν 14, 2020 1:58:00 ΠΜ org.apache.catalina.startup.Catalina load INFO: Server initialization in [2,379] milliseconds Ιουν 14, 2020 1:58:00 ΠΜ org.apache.catalina.core.StandardService startInternal INFO: Starting service [Catalina] Ιουν 14, 2020 1:58:00 ΠΜ org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet engine: [Apache Tomcat/9.0.35] Ιουν 14, 2020 1:58:02 ΠΜ org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Ιουν 14, 2020 1:58:03 ΠΜ org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-8081"] Ιουν 14, 2020 1:58:03 ΠΜ org.apache.catalina.startup.Catalina start INFO: Server startup in [2,449] millisecondsHTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/web-customer-tracker/] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
我有两台电脑,第一台运行程序如果改变 @WebServlet("/") 我无法解释为什么。 在这里它没有 运行.
我还重新安装了 eclipse 和 tomcat。 日蚀 2019 阿帕奇 9 java 版本“1.8.0_251” Java(TM) SE 运行时环境(build 1.8.0_251-b08) Java HotSpot(TM) 64 位服务器 VM(内部版本 25.251-b08,混合模式)
有人可以帮助我吗?
只需右键单击您的 servlet 并选择 Run As > Run on Server
。