zoukankan      html  css  js  c++  java
  • 登陆中发现css页面不见了,变成了光秃秃的输入框问题

     变成了这种光秃秃的状态;

    这种状态一般是css文件被过滤器拦截了,

    当时的过滤器代码

    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 net.wanho.web.EncodingRequest;
    
    public class EncodingFilter implements Filter {
    
        private FilterConfig filterConfig = null;
    
        public void init(FilterConfig fConfig) throws ServletException {
            this.filterConfig = fConfig;
        }
    
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
    
            String encoding = filterConfig.getInitParameter("charset");
            // 处理post请求编码问题
            request.setCharacterEncoding(encoding);
    //            response.setCharacterEncoding(encoding);
            response.setContentType("text/html;charset=" + encoding);
            chain.doFilter(request, response);
        }
    
        public void destroy() {
    
        }
    
    }

    这种情况就是一下子把css页面也过滤掉了,所以我们要再增加一个过滤页面;

    import javax.servlet.*;
    import javax.servlet.annotation.WebFilter;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    @WebFilter("*.css")
    public class CSSFilter implements Filter {
        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
    
        }
    
        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    
    
    //            response.setCharacterEncoding(encoding);
            response.setContentType("text/css;charset=utf-8");//注意这里text/css
            chain.doFilter(request, response);
    
        }
    
        @Override
        public void destroy() {
    
        }
    }

    然后重启一下编辑器,清除浏览器缓存,再试一次

  • 相关阅读:
    [转载]从程序员到项目经理:思维一换天地宽
    针对后台TCP服务F5健康检查配置
    [转载]生活在 Emacs 中
    [转载]为何 Emacs 和 Vim 被称为两大神器
    Emacs文件命令
    功能点估算速记
    [转载]CMMI之功能点估算法:EI、EQ和EO
    一些有用的 Emacs 配置(窗口快速切换、一键透明效果、任意位置删除整行等)
    refiling失败报错Invalid function: org-preserve-local-variables
    Cognos定时Email发送报表数据功能
  • 原文地址:https://www.cnblogs.com/sunstudy/p/13259155.html
Copyright © 2011-2022 走看看