第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

為什么我的過濾器案例得不到老師講的“死循環(huán)”結(jié)果?

FirstFilter.java代碼:

package com.imooc.filter;


import java.io.IOException;


import javax.servlet.Filter;

import javax.servlet.FilterChain;

import javax.servlet.FilterConfig;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


public class FirstFilter implements Filter {


public void destroy() {

System.out.println("destroy---FirstFilter");

}


public void doFilter(ServletRequest request, ServletResponse response,

FilterChain chain) throws IOException, ServletException {

System.out.println("start.......doFilter()---FirstFilter");

//chain.doFilter(request,response);

HttpServletRequest req=(HttpServletRequest) request;

HttpServletResponse response2=(HttpServletResponse) response;

//重定向

response2.sendRedirect(req.getContextPath()+"/main.jsp");

System.out.println("end.......doFilter()---FirstFilter");

}


public void init(FilterConfig filterConfig) throws ServletException {

System.out.println("init---FirstFilter");

}


}


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_2_5.xsd" id="WebApp_ID" version="2.5">

? <display-name>ImoocFilte</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>

? ? <filter>

? ? ? ? <filter-name>FirstFilter</filter-name>

? ? ? ? <filter-class>com.imooc.filter.FirstFilter</filter-class>

? ? ? ? <init-param>

<param-name>name</param-name>

<param-value>zhangsan</param-value>

</init-param>

? ? </filter>

? ? <filter-mapping>

? ? ? ? <filter-name>FirstFilter</filter-name>

? ? ? ? <url-pattern>/index.jsp</url-pattern>

? ? ? ? <dispatcher>REQUEST</dispatcher>

? ? </filter-mapping>

? ? ?<filter-mapping>

? ? ? ? <filter-name>FirstFilter</filter-name>

? ? ? ? <url-pattern>/main.jsp</url-pattern>

? ? </filter-mapping>

? ?<!--?

? ?<filter>

? ? ? ? <filter-name>SecondFilter</filter-name>

? ? ? ? <filter-class>com.imooc.filter.SecondFilter</filter-class>

? ? </filter>

? ? <filter-mapping>

? ? ? ? <filter-name>SecondFilter</filter-name>

? ? ? ? <url-pattern>/index.jsp</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>





main.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 'main.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 Main page. <br>

? </body>

</html>







正在回答

1 回答

你服務(wù)器啟動后是直接訪問main.jsp頁面嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么我的過濾器案例得不到老師講的“死循環(huán)”結(jié)果?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號