Tomcat 8.0.44找不到资源

时间:2017-05-23 14:23:06

标签: java rest maven jersey

所以我有一个Tomcat 8.0.44。我的网站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">

<display-name>server-web</display-name>
<context-param>
    <param-name>isLog4jAutoInitializationDisabled</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>server-web/src/main/webapp/WEB-INF/log4j2.xml</param-value>
</context-param>
<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>
<servlet>
    <servlet-name>server-web</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>server</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>server-web</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

我的log4j配置都没问题,Tomcat也找不到像这个类这样的简单资源:

@Path("/")
public class InitServerPoint {
Logger logger = LogManager.getLogger(InitServerPoint.class);

@GET
@Produces("text/html")
public Response getStartingPage() throws IOException {
    logger.error("Init log message");
    String output = "file path: " + file.getAbsolutePath() + "<h1>Hello 
 World!<h1>"
            + "<p>RESTful Service is running ... <br>Ping @ " + new 
 Date().toString() + "</p<br>";
    return Response.status(200).entity(output).build();

}

}

当我输入http://localhost:8080/server-web/时,它会返回404.你能帮我配置一下吗?

0 个答案:

没有答案