
Jsp
意 外
这个作者很懒,什么都没留下…
展开
-
用户登录检查实现
1、登录页面Java代码public class login extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String username = req.getParameter("username"); String pa原创 2020-12-09 13:39:30 · 417 阅读 · 0 评论 -
Java中Filter过滤器的配置
1、Java代码public class CharacterEncodingFilter implements Filter { // 初始化 public void init(FilterConfig filterConfig) throws ServletException { System.out.println("已经初始化了..."); } public void doFilter(ServletRequest servletRequest,原创 2020-12-09 11:58:46 · 369 阅读 · 0 评论 -
Session和Cookie的区别
Session使用场景:原创 2020-12-03 22:02:22 · 132 阅读 · 0 评论 -
Session注销方式
1、手动注销(模拟用户注销) HttpSession session = req.getSession(); session.removeAttribute("user"); // 注销session session.invalidate();2、服务器自动注销(模拟服务器超时注销) <!-- 设置session的默认的失效时间 --> <session-config> <!-- 1分钟后失效,默认单位为分钟 --原创 2020-12-03 21:58:26 · 2825 阅读 · 0 评论 -
Session实战
1、pojo类public class User { private String name; private int id; public User(String name, int id, int age) { this.name = name; this.id = id; this.age = age; } private int age; public String getName() {原创 2020-12-03 21:55:51 · 182 阅读 · 0 评论 -
Cookie实战
public class Cookie01 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); resp.setCharacterEncoding("utf-8"原创 2020-12-03 21:54:12 · 135 阅读 · 0 评论 -
Jsp登录验证
1、Jsp代码:<html><body><h2>你好,请输入用户名和密码!</h2><%--${pageContext.request.contextPath} 代表当前项目--%><form action="${pageContext.request.contextPath}/login" method="get" pageEncoding:<%@ page pageEncoding="UTF-8"%>>原创 2020-12-01 21:36:32 · 430 阅读 · 0 评论