Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Filter¹ýÂËÆ÷ʹÓÃ

±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔسö´¦£ºhttp://blog.csdn.net/royaki/archive/2009/05/07/4159279.aspx
 1¡¢½¨Á¢Ò»¸öServlet²¢ÇÒʵÏÖFilter½Ó¿Ú
¸ÃÀàÐèҪʵÏÖFilter½Ó¿ÚÖеÄinit()   doFilter()    destory()·½·¨
ÆäÖÐinit()·½·¨×Ô¶¯ÔÚÏîÄ¿Æô¶¯µÄʱºò¼ÓÔØ£¬doFilter()ÔÚµ÷ÓÃxmlÅäÖõÄ·¾¶ÊǼÓÔØ£¬destory()·½·¨ÔÚÍ˳öÏîÄ¿µÄʱºò½øÐС£
public class TestFilter implements Filter{
public void init(FilterConfig filterConfig) throws ServletException{
System.out.println("³õʼ»¯Filter");
}
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws Exception{
System.out.println("½øÐÐdoFilter");
chain(request,response);     //ʹÓÃÕâÒ»¾ä¼ÌÐøServletÇëÇó
}
public void destory(){
System.out.println("¹ýÂËÆ÷Ïú»Ù");
}
}
2¡¢ÔÚxmlÖÐÅäÖÃFilter
<filter>
<filter-name></filter-name>
<filter-class></filter-class>
</filter>
<filter-mapping>
<filter-name></filter-name>
<url-pattern>/*</url-pattern> //ÕâÀïÏë¶ÔÄĸö·¾¶½øÐйýÂ˾ÍÌîдÄĸö
</filter-mapping>
Ó¦Óãº
±àÂë¹ýÂË
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws Exception{
System.out.println("½øÐÐdoFilter"±àÂë¹ýÂË);
try
  {
   request.setCharacterEncoding("GB2312") ;
  }
  catch (Exception e)
  {
   e.printStackTrace();
  }
 
  chain.doFilter(request,response) ;
}
xmlÖеÄÅäÖãº
<url-pattern>/*</url-pattern>  ¶ÔËùÓÐÇëÇ󶼹ýÂË
Ãô¸Ð´Ê»ã¹ýÂË
public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws IOExce


Ïà¹ØÎĵµ£º

java µÄ½Ó¿Úµ½µ×Æðʲô×÷ÓÃ

 ÎÒÏ룬¿ÉÄܲ»Ö¹ÎÒÒ»¸öÈËÓÐÕâ¸öÒÉÎÊ£¬ËùÒÔ£¬°ÑËüÌù³öÀ´¡£
 
¡¡¡¡ÏÂÃæÊÇmadaiºÍclkrst¸øÎҵĻشð¡£
 
¡¡¡¡ÔÚ´ËллÁ½Î»¡£
 
¡¡¡¡ÎÒµÄÎÊÌâÊÇ£º
 
¡¡¡¡java µÄ½Ó¿Úµ½µ×Æðʲô×÷Óã¿
 
¡¡¡¡1¡¢´ÓÊéÖп´µ½µÄÊÇjava³ÌÐòµÄ½Ó¿ÚÖÐÖ»¶¨ÒåÁ˳£Á¿¼°¿Õ·½·¨£¬¿ÕµÄ·½·¨ÓÐʲôÓÃÄØ£¿»¹ÒªÔÚÀàÖÐÐ ......

javaÖÐʹÓÃÕýÔò±í´ïʽ

 ×ª×Ô£ºhttp://student.csdn.net/space.php?uid=52781&do=blog&id=15267&cid=50252
javaÖÐʹÓÃÕýÔò±í´ïʽ
¼ÆËã»úרҵ±ÏÒµ»òÕßʹÓùýUnix¡¢PerlµÈ²úÆ·µÄ¶ÁÕßÒ»¶¨¶ÔÕýÔò±í´ïʽÓÐÒ»¶¨µÄÓ¡Ïó,¼´Ê¹Ã»ÓнӴ¥¹ýÕýÔò±í´ïʽҲ²»Òª±»ËüµÄÍâòËùÏŵ¹¡£ËäÈ»×öµ½¾«Í¨ÕýÔò±í´ïʽ±È½ÏÄÑ£¬µ«ÊÇÄܹ»ÕÆÎÕËüµÄ»ù±¾Ó¦ÓÃÈ´ÊÇ· ......

JavaÖÐIOÁ÷µÄʹÓÃÀý×Ó

 import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundExce ......

JAVA¾²Ì¬·½·¨µÄͬ²½ÎÊÌâ~~~~~~~~~~~~~

Ò»Ö±±»Í¬²½¸ãµÃÔÎͷתÏò£¬½ñÌìÓöµ½ÁËҪд¾²Ì¬·½·¨£¬×ܵ£ÐĻ᲻»áÓÐͬ²½ÎÊÌ⣬½á¹û¿´ÁËÒÔÏÂһϯ»°£¬»íÈ»¿ªÀÊ~~
Every method of java will have a stack, and every invokation on that
method will have it's own 'stack frame'. So the locale data of one
method invokation will not affect others.
Please do not c ......

JavaÖеÄAscÂëÓë×Ö·û»¥Ïàת»¯

package com.test;
public class Jm1 {
private static int asnum;
private static char stchar;
public static void main(String[] args) {
System.out.println(getAsc("A"));
System.out.println(backchar(99));
}
/**
* ×Ö·ûתASC
*
* @param st
* @return
*/
public static int get ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ