易截截图软件、单文件、免安装、纯绿色、仅160KB

java filter用法大全

关键字: filter
    过滤器Filter也具有生命周期:init()->doFilter()->destroy(),由部署文件中的filter元素驱动。在servlet2.4中,过滤器同样可以用于请求分派器,但须在web.xml中声明,<dispatcher>INCLUDE或FORWARD或REQUEST或ERROR</dispatcher>该元素位于filter-mapping中。
一、批量设置请求编码
Java代码
public class EncodingFilter implements Filter {   
  
    private String encoding = null;   
  
    public void destroy() {   
         encoding = null;   
     }   
  
    public void doFilter(ServletRequest request, ServletResponse response,   
             FilterChain chain) throws IOException, ServletException {   
         String encoding = getEncoding();   
        if (encoding == null){   
             encoding = "gb2312";   
         }   
         request.setCharacterEncoding(encoding);// 在请求里设置上指定的编码   
         chain.doFilter(request, response);   
     }   
  
    public void init(FilterConfig filterConfig) throws ServletException {   
        this.encoding = filterConfig.getInitParameter("encoding");   
     }   
  
    private String getEncoding() {   
       &nbs


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

Effective java 代码优化实例

package chape7;
/**
* 檢查參數的有效性
*    當編寫方法或者構造器時,應該考慮他的參數有什麽限制 應該吧這些限制寫在文檔中,並且在這個方法的開頭 ......

java exception java异常汇总(3)

java exception 解决方案 - 我的异常网|异常|exception   791 - java.lang.NoSuchMethodError 792 - RuntimeException 793 - org.hibernate.exception.SQLGrammarException 794 - Internal Error 795 - 自定义异常 796 - org.dom4j.DocumentException 797 - java.net.SocketException 798 - Exception对象 799 - SQLE ......

Java Application 直接通过jndi连接数据库

 使用jar包:
 commons-pool-1.5.3.jar,tomcat-naming-common.jar,commons-pool-1.5.3-bin.zip,commons-dbcp.jar
 注意:jdbc 驱动要与数据库兼容.
 package test.comm;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Hashtable;
import javax.naming.InitialCont ......

java 全排列算法

 import java.util.Arrays;
/**
 * 求一个数组的全排列算法
 * @author Administrator
 */
public class Pai { 
 public void pai(char[] array,int start,int end){
  System.out.println(" -- 组合 "+start+" 到 "+end+" --");
  if(start==end){
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号