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
Ïà¹ØÎĵµ£º
ת£ºhttp://www.ibm.com/developerworks/cn/java/j-jtp06197.html
2007 Äê 7 ÔÂ 05 ÈÕ
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖÆµÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£ÔÚÕâÆÚµÄ&nb ......
ÍøÉÏ¿´µ½Ò»Ð©¸Õ¿ªÊ¼Ñ§»òÊÇ»¹Ã»ÓпªÊ¼Ñ§javaµÄͬѧ£¬¾³£ÎÊ£º“Õâ¸öjava£¬ÎÒ¸ÃÔõôѧ£¬Ñ§Ê²Ã´ÄØ£¿”£¬ÎÒÏë¸øËûÃÇ˵һÏ¡£¿ÉÊÇÎÒµÄÄÜÁ¦ÓÐÏÞ¡£ËùÒÔÎÒÒ²²»ºÃ¶Ôij¸öͬѧ¾ßÌåµÄ˵ʲô£¬¿ÉÊÇ£¬½ñÌìÔÚÍøÉÏ¿´µ½Ò»ÕÅͼƬ¡£¸Ð¾õ¶Ô´ó¼ÒÌá³öµÄÕâ¸öÎÊÌâÓиöºÜºÃµÄ½âÊÍ˵Ã÷¡£
  ......
javaÖеķ´Éä¾³£±»ÓÃÔÚһЩ¿ò¼Ü´î½¨ÉÏ£¬ËûÄܹ»ÈÃÎÒÃǺܷ½±ãµÄ¶Ô×Ô¼ºÎ´À´½«Ê¹ÓõÄÀ࣬·½·¨ºÍ±äÁ¿½øÐзÃÎÊ¡£¸öÈ˾õµÃÓÐÖֺڿ͵ÄζµÀÔÚÀïÃæ¡£µ±ÎÒÃÇÖªµÀÒ»¸öÀàµÄÀàÃûºó£¬ÎÒÃÇ»ù±¾ÉÏ¿ÉÒÔʹÓ÷´ÉäµÄµ½ËüµÄÒ»ÇС£°üÀ¨ËûµÄprivateµÄ·½·¨ºÍ±äÁ¿µÈ(µ±È»·ÃÎÊËûÃǵÄʹÓÃÐèҪʹÓõÄÊÇgetDeclared***(**))¡£ÁíÍ⣬¾Ý ......
JavaÊäÈëÊý¾ÝÁ÷
ÔÚJavaÖУ¬ÎÒÃǰÑÄܹ»¶Áȡһ¸ö×Ö½ÚÐòÁеĶÔÏó³Æ×÷Ò»¸öJavaÊäÈëÊý¾ÝÁ÷;¶øÎÒÃǰѹ»Ð´Ò»¸ö×Ö½ÚÐòÁгÆ×÷Ò»¸öÊä³öÁ÷¡£ËüÃÇ·Ö±ðÓɳéÏóÀà InputStreamºÍOutputStreamÀà±íʾ¡£ÒòÎªÃæÏò×Ö½ÚµÄÁ÷²»·½±ãÓÃÀ´´¦Àí´æ´¢ÎªUnicode£¨Ã¿¸ö×Ö·ûʹÓÃÁ½¸ö×Ö½Ú)µÄÐÅÏ¢¡£ËùÒÔJava ÒýÈëÁËÓÃÀ´´¦ÀíUnicode×Ö·ûµÄÀà²ã´Î£¬ÕâЩÀàÅÉÉú× ......
JavaºÍÆäËûÓïÑÔ²»Í¬µÄÊÇ£¬JavaÊÇÔËÐÐÓÚJavaÐéÄâ»ú(JVM)¡£Õâ¾ÍÒâζ×űàÒëºóµÄ´úÂëÊÇÒÔÒ»ÖÖºÍÆ½Ì¨Î޹صĸñʽ±£´æµÄ£¬¶ø²»ÊÇijÖÖÌØ¶¨µÄ»úÆ÷ÉÏÔËÐеĸñʽ¡£ÕâÖÖ¸ñʽºÍ´«Í³µÄ¿ÉÖ´ÐдúÂë¸ñʽÓкܶàÖØÒªµÄÇø±ð¡£¾ßÌåÀ´Ëµ£¬²»Í¬ÓÚC»òÕߣÃ++³ÌÐò£¬Java³ÌÐò²»ÊÇÒ»¸ö¶ÀÁ¢µÄ¿ÉÖ´ÐÐÎļþ£¬¶øÊÇÓɺܶà·Ö¿ªµÄÀàÎļþ×é³É£¬Ã¿¸öÀàÎļþ¶ÔÓ¦Ò»¸ö ......