(一)、经常用的过滤器
1
package com.ascent.util;
2
3
import java.io.IOException;
4
import javax.servlet.Filter;
5
import javax.servlet.FilterChain;
6
import javax.servlet.FilterConfig;
7
import javax.servlet.ServletException;
8
import javax.servlet.ServletRequest;
9
import javax.servlet.ServletResponse;
10
import javax.servlet.UnavailableException;
11
12
/** *//**
13
* Example filter that sets the character encoding to be used in parsing the
14
* incoming request
15
*/
16
public class SetCharacterEncodingFilter implements Filter
{
17
18
/** *//**
19
* Take this filter out of service.
20
*/
21
public void destroy()
{
22
}
23
/** *//**
24
* Select and set (if specified) the character encoding to be used to
25
* interpret request parameters for this request.
26
*/
27
public void doFilter(ServletRequest request, ServletResponse response,
28
FilterChain chain)throws IOException, ServletException
{
29
30
request.setCharacterEncoding("gb2312");
31
32
// 传递控制到下一个过滤器
33
chain.doFilter(request, response);
34
}
35
36
public void init(FilterConfig filterConfig) throws ServletException
{
37
}
38
}
39

2

3

4

5

6

7

8

9

10

11

12


13

14

15

16



17

18


19

20

21



22

23


24

25

26

27

28



29

30

31

32

33

34

35

36



37

38

39

(二)、购物车类代码































































































(三)、分页算法











































































































