my web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="3.1">
<display-name>restapp</display-name>
<distributable/>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
My main Application class looks something like this:
package com.example.restapp;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/api")
public class RestApplication extends Application {}
my directory structure looks like this:
My jax-rs rest app endpoint is successfully served from http://localhost:8080/restapp/api/test
My index.jsp is successfully served from http://localhost:8080/restapp/index.jsp
And yet, when a GET is performed on http://localhost:8080/restapp/
Tomcat returns with a 404.
While I could fix this with some URL rewrites and such, I know Tomcat supports this and would just like to understand why this isn't working. I've tried any number of combinations of adding servlet
and servlet-mapping
tags, etc., and have given up and now I'm just looking for why this is broken and what I can do to resolve this. Java servers are not my friend today.
According Apache Tomcat 8 Configuration Reference , you must follow war
file naming conventions:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.