当我点击运行时,eclipse总是走错路

时间:2015-10-05 13:43:13

标签: java eclipse tomcat

在Eclipse中,当我单击运行时,它总是转到Eclipse浏览器上的错误路径。我做错了什么?

例如;当我单击testGet.java并单击Run时,Eclipse将转到http://localhost:8080/slwebservice/WEB-INF/classes/service/testGet.java。但是,在教程或Java Web视频中,Eclipse会转到一个完整的URL,如http://localhost:8080/slwebservice/test/或其他东西。 我使用的是Windows 7,Java SDK 1.7,Eclipse Luna和Tomcat 7.0。我不熟悉Java。 这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
    <servlet-name>myrest</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>service</param-name>
        <param-value>testGet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>myrest</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

当我点击运行时,似乎Tomcat上没有例外。这是我的Tomcat日志:

十月 05, 2015 9:07:28 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:slervice' did not find a matching property.
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/7.0.64
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Aug 19 2015 17:18:06 UTC
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         7.0.64.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 7
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            6.1
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:\Program Files\Java\jdk1.7.0_79\jre
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.7.0_79-b15
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 7.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
十月 05, 2015 9:07:28 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: 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\jdk1.7.0_79\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_79/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.7.0_79\bin;D:\JAVASDK\android_sdk\tools;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\PWRS\shared;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\BINN;C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Sybase\SQL Anywhere 8\win32;C:\Program Files (x86)\Sybase\Shared\win32;C:\Program Files (x86)\Sybase\Shared\Sybase Central 4.1;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Sybase\Shared\PowerBuilder;;C:\Program Files (x86)\Sybase\SQL Anywhere 10\x64;C:\Program Files (x86)\Sybase\SQL Anywhere 10\win32;C:\Program Files (x86)\Sybase\SQL Anywhere 10\Sybase Central 5.0.0\win32;C:\Program Files\SQL Anywhere 12\bin64;C:\Program Files\SQL Anywhere 12\bin32;C:\Program Files (x86)\Sybase\PowerBuilder 12.5;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5.4 & MySQL Utilities 1.5.4 1.5\Doctrine extensions for PHP\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\apache-maven\bin;;D:\eclipse;;.
十月 05, 2015 9:07:28 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
十月 05, 2015 9:07:28 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
十月 05, 2015 9:07:28 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 698 ms
十月 05, 2015 9:07:28 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina 
十月 05, 2015 9:07:28 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.64
十月 05, 2015 9:07:29 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\javatest\slservice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\slervice\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
十月 05, 2015 9:07:30 下午 org.apache.catalina.startup.TldConfig execute
信息: 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.
十月 05, 2015 9:07:31 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
十月 05, 2015 9:07:31 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
十月 05, 2015 9:07:31 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2515 ms

任何帮助都将不胜感激。

此致 肯

1 个答案:

答案 0 :(得分:0)

你在这里用什么?用SpringMVC?不知道你要求的是什么...我认为因为你是中国人...

无论哪种方式,它看起来像春天,因此应该更改此段,

<servlet-mapping>
    <servlet-name>myrest</servlet-name>
    <url-pattern>/</url-pattern>  // remove the *
</servlet-mapping>
</web-app>