資源簡介
查看詳情請搜索文章[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個文件信息
評論
共有 條評論