0

我正在尝试在我的应用程序中将 jsp 文件作为欢迎文件运行。

这是我的 web.xml 文件:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>RESTServiceFrontEnd</servlet-name>
        <servlet-class>
                com.sun.jersey.spi.container.servlet.ServletContainer
            </servlet-class>
        <init-param>
          <param-name>javax.ws.rs.Application</param-name>
          <param-value>
                    enceladus.server.rest.FrontEnd
                </param-value>
        </init-param>
        <init-param>
          <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
          <param-value>
                    com.sun.jersey.api.container.filter.LoggingFilter
                </param-value>
        </init-param>
        <init-param>
          <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
          <param-value>
                    com.sun.jersey.api.container.filter.LoggingFilter
                </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>RESTServiceFrontEnd</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping>

    </web-app>

和我的jsp文件:

        <%@page import="enceladus.server.objects.Management"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <%
        Management m = Management.getInstance();
    System.out.println("asdasfdfsgsdgdafgdfg");
    %>
</body>
</html>

当我删除除欢迎文件之外的所有内容时,它工作得很好。我还有一条来自我的服务器的消息:

19-lug-2012 11.08.22 com.sun.jersey.api.container.filter.LoggingFilter$Adapter 完成信息:1 * 服务器出站响应 1 < 404 1 <

提前致谢

4

2 回答 2

3

更改<url-pattern>RESTService。

  <servlet-mapping>
        <servlet-name>RESTServiceFrontEnd</servlet-name>
        <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

PS:在请求 REST 服务时,您的 URL 应该是http://localhost/contextFolder/rest/method

于 2012-07-19T09:28:13.603 回答
2

请按照welcome-file-list以下定义servlet mappingweb-app_2_3.dtd

 <servlet-mapping>
   <servlet-name>RESTServiceFrontEnd</servlet-name>
  <url-pattern>/*  </url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
于 2012-07-19T09:29:14.310 回答