package com.gyarmy.demo4;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
impor...
1\使用HttpServletRequestWrapper 包装类
2\重写getParameter \ getParameterValues \ getParameterMap 三个函数
3\ 配置 web.xml
核心过滤器代码
package com.gyarmy.demo4;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import ja...
分析清楚逻辑结构
cookie + session + filter 技术运用
防止伪造cookie
需要改进的地方: cookie加密技术
package com.gyarmy.demo4;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletExce...
1\了解过滤器的声明周期
2\过滤器的web.xml文件的配置
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.gyarmy.demo1.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>u...
[该文章已设置加密,请点击标题输入密码访问]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<he...
factory.java文件实现
package com.itheim.customers.dao.factory;
import java.util.ResourceBundle;
import com.itheim.customers.dao.CustomerDao;
/*
* 这是 用于创建 dao的工厂 类 ,
*
* 工厂类 很多时候 会被 弄成单例的
*
*
*/
public class DaoFactory {
private DaoFactory(){};
//创建一个...
token生成代码:
<%
//生成一个唯一的串
String token = UUID.randomUUID().toString();
// 将这个唯一的串 存到 session 域对象中去
session.setAttribute("token_session", token);
%>
验证token代码
<%@page import="java.util.UUID"%>
<%@ page language="java" contentType="text/...
两个文件
1\ JdbcUtils.java 的源代码
package com.gyarmy.dbutils;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;
import com.gyarmy.domain.*;
im...
package com.gyarmy.person;
import java.lang.reflect.Field;
import org.junit.Test;
public class TestPerson {
@Test
public void test2() throws Exception{
Class cls1 = Class.forName("com.gyarmy.person.Person");
Field nameField = cls1.getDeclaredField("name");
//打开访问权限
nameFi...
package com.gyarmy.c3p0;
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.junit.Test;
import com.gyramy.utils.JdbcUtils;
import com.mchange.v2.c3p0.*;
public class C3P0Test {
@Test
public void test2(){
Connection conn =null;
PreparedStatement...
用动态代理调用连接池出现问题, 不太懂得原理, 只找到了解决方法:
原代码出错位置;
Connection proxyConn = (Connection) Proxy.newProxyInstance(TestMyData.class.getClassLoader(), conn.getClass().getInterfaces(), new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object...
package com.gyarmy.datesource;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.junit.Test;
public class TestData1 {
@Test
public void test1(){
System.out.println("test1");
//继承
Cat car1 = new Cat()...
table 是 innodb 非 myisam
package com.gyarmy.transcation;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
import com.gyarmy.utils.JdbcUtils;
public class TestTranscation {
@Test
public void test1(){...
package com.itheima.login.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import com.itheima.login.domain.User;
import com.itheima.login.utils.JdbcUtils;
public class UserDao {
//查询 单个 用户 , 这里 是dao的核心类, 封装了对数据...