Tomcat:404请求的资源不可用

时间:2016-08-05 11:04:35

标签: java oracle hibernate tomcat

我正在使用hibernate框架。这是hibernate.cfg.xml文件代码。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  <property name="hibernate.connection.password">702711</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@10.69.18.24:1521:xe</property>
  <property name="hibernate.connection.username">system</property>
  <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>

  <mapping class="com.eccSports.entity.UserEntity"/>
 </session-factory>
</hibernate-configuration>

web.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>ECCSports</display-name>
  <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>Jersey REST Service</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.eccSports.api</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>
</web-app>

This is the directory structure.

所有文件都在那里,但我仍然得到404.我重启了服务器几次,但仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

我可以看到你正在使用运动衫和冬眠....确保你遵循以下给定的步骤......

  1. 无论您发送的是哪个网址,都必须包含您的网址格式:<url-pattern>/api/*</url-pattern>

    例如:      http://localhost:8080/yourpath/api/classlevelurl/

  2. 确保您正在编写的服务位于com.eccSports.api包中。正如您在web.xml中提到的那样