首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

过滤器导致网站变乱,该如何解决

2012-02-03 
过滤器导致网站变乱我的登录页面是这样的HTML code!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transiti

过滤器导致网站变乱
我的登录页面是这样的

HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE></TITLE><META http-equiv=Content-Type content="text/html; charset=utf-8"><LINK href="css/admin.css" type="text/css" rel="stylesheet"></HEAD><BODY onload=document.form1.name.focus();><TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" bgColor=#002779 border=0>  <TR>    <TD align=middle>      <TABLE cellSpacing=0 cellPadding=0 width=468 border=0>        <TR>          <TD><IMG height=23 src="images/login_1.jpg"           width=468></TD></TR>        <TR>          <TD><IMG height=147 src="images/login_2.jpg"             width=468></TD></TR></TABLE>      <TABLE cellSpacing=0 cellPadding=0 width=468 bgColor=#ffffff border=0>        <TR>          <TD width=16><IMG height=122 src="images/login_3.jpg"             width=16></TD>          <TD align=middle>            <TABLE cellSpacing=0 cellPadding=0 width=230 border=0>              <FORM name="login_form" action="servlet/logincheck" method="post">              <TR height=5>                <TD width=5></TD>                <TD width=56></TD>                <TD></TD></TR>                <TR height=5>                <TD width=5></TD>                <TD width=56>登录类型:</TD>                <TD>                <select name="loginType" style=" width:100px;">                  <option value="1">参考人员</option>                  <option value="2">出题者</option>                  <option value="3">系统管理员</option>                </select>                </TR>              <TR height=36>                <TD></TD>                <TD>用户名</TD>                <TD><INPUT style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"                   maxLength=30 size=24 value="admin" name="username"></TD></TR>              <TR height=36>                <TD>&nbsp; </TD>                <TD>口 令</TD>                <TD><INPUT style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"                   type=password maxLength=30 size=24 value="admin" name="password"></TD></TR>              <TR height=5>                <TD colSpan=3></TD></TR>              <TR>                <TD>&nbsp;</TD>                <TD>&nbsp;</TD>                <TD><INPUT type=image height=18 width=70                   src="images/bt_login.gif"></TD></TR></FORM></TABLE></TD>          <TD width=16><IMG height=122 src="images/login_4.jpg"             width=16></TD></TR></TABLE>      <TABLE cellSpacing=0 cellPadding=0 width=468 border=0>        <TR>          <TD><IMG height=16 src="images/login_5.jpg"           width=468></TD></TR></TABLE>      <TABLE cellSpacing=0 cellPadding=0 width=468 border=0>        <TR>          <TD align=right><A href="http://www.865171.cn/" target=_blank><IMG             height=26 src="images/login_6.gif" width=165             border=0></A></TD></TR></TABLE></TD></TR></TABLE></BODY></HTML> 


我的过滤器是这样的
Java code
package cn.hatzhou.servlet;import java.io.IOException;import java.io.PrintWriter;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.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import com.sun.net.httpserver.Filter.Chain;public class LoginFilter implements Filter {    public void destroy() {            }    public void doFilter(ServletRequest request, ServletResponse response,        FilterChain chian) throws IOException, ServletException {        HttpServletRequest req = (HttpServletRequest)request;        HttpSession session = req.getSession();        if (session.getAttribute("username") != null) {            chian.doFilter(request, response);        }else{            request.getRequestDispatcher("index.htm").forward(request, response);        }    }    public void init(FilterConfig arg0) throws ServletException {        System.out.println("过滤器初始化");    }    }

web.xml中过滤器是这样配置的
XML code
<filter>        <filter-name>LoginFilter</filter-name>        <filter-class>cn.hatzhou.servlet.LoginFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>LoginFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>

问题就是 本来登录的页面很整齐,但是配置了过滤器之后图片显示叉叉,css基本也没用了,肿么办


[解决办法]
/*是过滤掉所有的,包括图片、js、css和html
要么在加个路径如:/×××/*
要么就改为*.jsp

热点排行