Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问Java动态Web项目中的资源时出现错误404_Java_Rest_Jsp_Servlets_Web.xml - Fatal编程技术网

访问Java动态Web项目中的资源时出现错误404

访问Java动态Web项目中的资源时出现错误404,java,rest,jsp,servlets,web.xml,Java,Rest,Jsp,Servlets,Web.xml,有人能告诉我如何设置我的项目结构和web.xml吗? 在java资源文件夹中的动态web项目中,我有一个servlet(类名:RestFulService),它提供一个JSON文件。 网页位于WebContent文件夹中,例如index.jsp。 该项目使用glassfish服务器发布。 这是我当前的web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001

有人能告诉我如何设置我的项目结构和web.xml吗? 在java资源文件夹中的动态web项目中,我有一个servlet(类名:RestFulService),它提供一个JSON文件。 网页位于WebContent文件夹中,例如index.jsp。 该项目使用glassfish服务器发布。 这是我当前的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">
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>RestFulService</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.javasrc, com.jersey.jaxb, com.fasterxml.jackson.jaxrs.json</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>RestFulService</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

index.jsp
休息服务
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.javasrc、com.jersey.jaxb、com.fasterxml.jackson.jaxrs.json
com.sun.jersey.api.json.POJOMappingFeature
真的
1.
休息服务
/*
访问JSON的链接工作得很好(),但是如果我想通过“”访问index.jsp,我得到的只是一个错误404页面。 谁能告诉我问题出在哪里?我必须改变什么才能让它工作?
我想问题出在web.xml中,但我不知道要更改什么。

请展示您的包装您的包装是什么意思?我看不出有可能在这里粘贴我的项目设置的图像…BCode-Java资源--RestFulService.Java-WebContent--WEB-INF--WEB.xml--index.jsp我认为这是结构的重要部分。您使用的是哪个IDE?你把
index.jsp
放在
WEB-INF
里面还是外面了?我已经读过了。是的,WEB-INF中只有WEB.xml。index.jsp位于WebContent文件夹中。