资源简介
查看详情请搜索文章[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.xm
文件 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个文件信息
相关资源
- 微课平台系统.
- SSM+websocket+freemarker+mybatis分页插件+多
- 疯狂java讲义第三版 光盘内容包含课件
- 订单管理系统Java swing poi
- Java Programming 9th Edition
- Professional Java EE Design Patterns
- JAVA开发某燃气公司气体管理系统
- 毕业设计-Struts2+Hibernate4.2+Spring3的学生
- 毕业设计-Struts2+Hibernate4.2+Spring3的健身
- 毕业设计-Struts2+Hibernate4.2+Spring3的SS
- 尚硅谷佟刚JavaWeb基础视频教程课件
- 架构师路线和java8.rar
- 韩顺平.循序渐进学.java.从入门到精通
- java+ssh+SQL+bootstrap网上订餐系统全套源
- selenium-java-2.44.0.jar包
- 博客系统javaWeb开发
- openstack rest api 调用
- Apache commons API(整套全版
- Java实现飞行棋源码
- FFmpegCommandHandler
- World Wind Java三维地理信息系统开发技
- 尚硅谷佟刚JavaWeb教学课件
- 30天学通Java项目案例开发光盘源码
- 【碉堡版】Java实现音乐播放器源码
- JAVA微商城平台系统源码带数据库
- java pdf 实现电子签章
- 面向对象技术与UML课件及源代码-by 南
- 北大青鸟S2使用Java实现面向对象编程
- kafka的java依赖包
- 完整J2EE架构的用户权限管理系统源码
评论
共有 条评论