通过HTML轻松休息是行不通的

时间:2014-11-26 10:57:30

标签: java

我有一个安静的网址。当我在浏览器中输入url时,java类的get调用返回输出。当我调用index.html文件时,它没有加载。我正在使用tomcat7

这是我的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">
<display-name>projectname</display-name>
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/projectnamedb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>${catalina.home}\conf\log4j.properties</param-value>
</context-param>
<context-param>
<param-name>inputPropertiesLocation</param-name>
<param-value>${catalina.home}\conf\projectDetails.properties</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
</web-app>

1 个答案:

答案 0 :(得分:0)

这里要知道两件事

1)您无法简单地键入http://index.html您必须提供索引页面的路径,例如http://projectname/path/to/index.html

2)另一种简单的方法是将index.html添加为欢迎页面。因此,当服务器启动时,它首先打开index.html页面。像

<welcome-file-list>  
    <welcome-file>path/to/index.html</welcome-file>  
</welcome-file-list>