资源简介

查看详情请搜索文章[Jsp+Servlet+JDBC新闻发布系统2.0] 2018-6-13更新了点内容,重新上传,之前的删除了。 内容:修复了一些bug,加了二级评论。

资源截图

代码片段和文件信息

package cn.nicecoder.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.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.nicecoder.util.BizConstant;
import cn.nicecoder.util.DBUtil;
import cn.nicecoder.util.StringUtil;

/**
 * 核心过滤器,提供登录验证和编码
 *-------------------------------
 * @author longtian
 * @date 2018年4月24日下午9:57:22
 * @description nicecoder.cn
 *-------------------------------
 */
@WebFilter(filterName=“/CoreFilter“ urlPatterns=“/*“)
public class CoreFilter implements Filter {

    public CoreFilter() {
        // TODO Auto-generated constructor stub
    }

public void destroy() {
// TODO Auto-generated method stub
}

public void doFilter(ServletRequest request ServletResponse response FilterChain chain) throws IOException ServletException {
request.setCharacterEncoding(“UTF-8“);
        response.setCharacterEncoding(“UTF-8“);
        
        String bizCode = request.getParameter(“bizCode“);

        //简单的权限控制
        boolean flag = true;
HttpServletRequest httpRequest = (HttpServletRequest)request;
if(BizConstant.BIZ_NEWS_0.getpCode().equals(bizCode)||BizConstant.BIZ_NEWS_1.getpCode().equals(bizCode)||BizConstant.BIZ_NEWS_3.getpCode().equals(bizCode)) {
 String username = request.getParameter(“username“);
 String password = request.getParameter(“password“);

 HttpSession session = httpRequest.getSession();
 if(StringUtil.isNotEmpty(username) && StringUtil.isNotEmpty(password)){
 if(!“meiyoumima“.equalsIgnoreCase(password)){
 flag = false; 
 }else{
 session.setAttribute(“username“ username);
 session.setAttribute(“password“ password);
 session.setMaxInactiveInterval(5 * 60);
 }
 }else{
 password = (String) session.getAttribute(“password“);
 if(!“meiyoumima“.equalsIgnoreCase(password)){
 flag = false; 
 }
 }
}

if(flag){
chain.doFilter(requestresponse);
}else{
request.getRequestDispatcher(“forbidden.jsp“).forward(request response);
}
}

public void init(FilterConfig fConfig) throws ServletException {
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-13 10:31  newspublishsystem\
     目录           0  2018-06-13 10:30  newspublishsystem\Myeclipse\
     文件       87808  2018-06-07 15:49  newspublishsystem\Myeclipse\jsp-api.jar
     文件     7760766  2018-06-07 16:19  newspublishsystem\Myeclipse\Myeclipse.mp4
     文件       95806  2018-06-07 15:45  newspublishsystem\Myeclipse\servlet-api-3.1.jar
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\
     文件         841  2018-04-27 15:29  newspublishsystem\newspublishsystem\.classpath
     文件         886  2018-04-25 16:47  newspublishsystem\newspublishsystem\.project
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\.settings\
     文件         555  2018-04-25 16:49  newspublishsystem\newspublishsystem\.settings\.jsdtscope
     文件         658  2018-04-25 16:56  newspublishsystem\newspublishsystem\.settings\org.eclipse.jdt.core.prefs
     文件         495  2018-04-25 16:49  newspublishsystem\newspublishsystem\.settings\org.eclipse.wst.common.component
     文件         345  2018-04-25 16:57  newspublishsystem\newspublishsystem\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-04-25 16:49  newspublishsystem\newspublishsystem\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-04-25 16:49  newspublishsystem\newspublishsystem\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\filter\
     文件        2876  2018-05-09 16:40  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\filter\CoreFilter.class
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\pojo\
     文件        2402  2018-05-10 13:52  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\pojo\Discuss.class
     文件        3415  2018-05-07 15:03  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\pojo\News.class
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\servlet\
     文件       15402  2018-06-13 10:08  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\servlet\CoreServlet.class
     文件        5333  2018-05-10 18:04  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\servlet\UploadImageServlet.class
     目录           0  2018-06-13 10:31  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\util\
     文件        5193  2018-05-04 17:01  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\util\AddressUtil.class
     文件        2175  2018-05-10 13:49  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\util\BizConstant.class
     文件        1106  2018-06-01 17:29  newspublishsystem\newspublishsystem\build\classes\cn\nicecoder\util\DBUtil.class
............此处省略216个文件信息

评论

共有 条评论