问答详情
源自:3-1 [Java Web] 第一个过滤器案例

我的jsp页面怎么没有打开呢?

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


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

    <filter>
        <filter-name>FirstFilter</filter-name>
        <filter-class>com.imooc.filter.FirstFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>FirstFilter</filter-name>
        <!-- /*代表了所有连接,如果是index前缀的,可以写成/index* -->
         <url-pattern>/*</url-pattern> 
    </filter-mapping>
</web-app>

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
    This is my JSP page. <br>
    <%
    System.out.println("处理过程完成");
     %>
  </body>
</html>


提问者:鲜衣 2016-08-18 16:26

个回答

  • 鲜衣
    2016-08-18 16:31:54

    原来是我没在doFilter方法里写:arg2.doFilter(arg0, arg1);