Java ¿ª·¢ÖÐÓõ½µÄ¼¸ÖÖ¹ýÂËÆ÷
ÔÚJavaÖÐÓÐʱ»áÓö¼ûÂÒÂëµÄÇé¿ö£¬ÕâÀïÌṩÁ˼¸ÖÖת»»·½·¨
£¨Ò»£©JavaÖеıàÂëת»»
£¨¶þ£©¿ÉÒÔÔÚweb.xmlÎļþÖÐÅäÖõÄ×Ô¼ºÐ´µÄ¹ýÂËÆ÷
µÚÒ»ÖÖ·½·¨×î¼òµ¥Ò²×î·½±ã£¬µ«ÊÇÖ»ÄÜÓÃÔÚÉÙÁ¿µÄµØ·½»òÊÇż¶ûÒ»Á½´ÎתÂ룬Èç¹û´óÃæ»ýʹÓþͲ»·½±ãÁË£¬Ò²´ó´óÔö¼ÓÁ˱àÂëÁ¿£¬Èç¹ûÄãµÄÏîÄ¿ÀïûÓÐÓÃSpringµÄ¿ò¼Ü¿ª·¢£¬ÓÃweb.xmlÅäÖÃ×Ô¶¨Òå¹ýÂËÆ÷¿ÉÒÔÒ»ÀÍÓÀÒݵĽâ¾ö
1.Ê×ÏÈÒª±àд×Ô¼ºµÄ¹ýÂËÆ÷Àà(ʵÏÖÁËjavax.servlet.Filter)£º
package fck.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class CodeFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filter) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
filter.doFilter(request, response);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
2.ÔÚweb.xmlÎļþÖбàд¹ýÂËÆ÷ÅäÖãº
<filter>
<!--CodeFilterÊÇ×Ô¼ºËæ±ãÈ¡µÄÃû×Ö-->
<filter-name>CodeFilter</filter-name>
<!--дºÃ¶ÔÓ¦µÄ¹ýÂËÆ÷ÀàµÄ·¾¶-->
<filter-class>fck.filter.CodeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CodeFilter</filter-name>
<!--“/*”´ú±íËùÓеÄÇëÇ󶼾¹ý¹ýÂË-->
<url-pattern>/*</url-pattern>
</filter-mapping>
Ö®ºó²»ÓÃÔÙ×öʲô´úÂëµÄ¸Ä±ä£¬¹ýÂËÆ÷¾Í½«ËùÓеķÃÎʶ¼×ªÂëÁË
(Èý)ʹä¯ÀÀÆ÷²»»º´æÒ³ÃæµÄ¹ýÂËÆ÷
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** *//**
* ÓÃÓÚµÄ
Ïà¹ØÎĵµ£º
ListµÄÓ÷¨
List°üÀ¨List½Ó¿ÚÒÔ¼°List½Ó¿ÚµÄËùÓÐʵÏÖÀà¡£ÒòΪList½Ó¿ÚʵÏÖÁËCollection½Ó¿Ú£¬ËùÒÔList½Ó¿ÚÓµÓÐCollection½Ó¿ÚÌṩµÄËùÓг£Ó÷½·¨£¬ÓÖÒòΪListÊÇÁбíÀàÐÍ£¬ËùÒÔList½Ó¿Ú»¹ÌṩÁËһЩÊʺÏÓÚ×ÔÉíµÄ³£Ó÷½·¨£¬Èç±í1Ëùʾ¡£
±í1 List½Ó¿Ú¶¨ÒåµÄ³£Ó÷½·¨¼°¹¦ÄÜ
´Ó±í1¿ÉÒÔ¿´³ö£¬List½Ó¿ÚÌṩµÄÊʺÏÓÚ×ÔÉíµÄ ......
ÕâÊÇһƪ¹ØÓÚ±àÂëµÄÎÄÕÂдµÄºÜºÃ!
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎÊÌâ¾ÍÏԵúÜÖØÒªÁË¡£
¡¡¡¡ÕâÊÇÒ»¸öÊÀ½ç·¶Î§ÄÚ¶¼´æÔÚµÄÎÊÌ⣬ËùÒÔ£¬JavaÌṩÁËÊÀ½çÐԵĽâ¾ö·½·¨¡£±¾ÎÄÃèÊöµÄ·½·¨ÊÇÓÃÓÚ´¦ÀíÖÐÎĵģ¬µ«ÊÇ£¬Íƶø¹ãÖ®£¬¶ÔÓÚ´¦À ......
java µÄÈ¥µô¿Õ¸ñ¿ÕÐеÄÀý×Ó£º
String so = "haolong, hei eip, "
+"ting, " +
& ......
¡¡¡¡XJad2.2£¨JavaÔ´´úÂë·´±àÒ빤¾ß£©
¡¡¡¡Á¢¼´ÏÂÔØ
¡¡¡¡XJadÊÇ»ùÓÚJadºËÐĵÄJavaÔ´³ÌÐò·´±àÒëÈí¼þ£¬ÄÚÖÃJad1.5.8e2¡£
¡¡¡¡XJad¿É´¦Àí¶à¸ö*.classÎļþ£¬¿ÉÒÔ´¦ÀíÎļþ¼ÐÄÚµÄËùÓÐÎļþ£¬ÉõÖÁ¿ÉÒÔ´¦Àí*.jarÎļþ¡£
¡¡¡¡XJad´øÓжàÒ³ÃæÎı¾±à¼Æ÷£¬·´±àÒëÍê³Éºó¿ÉÒÔÖ±½Ó±à¼²é¿´£¬±à¼Æ÷Ö§³ÖjavaÓï·¨µÄ¸ßÁÁÏÔʾ¹¦ÄÜ¡£
¡¡¡¡ ......
²Î¿¼ÍøÉϵÄһЩ×ÊÁÏ£¬×Ô¼ºÑжÁÁËÒ»·¬£¬ÓÃjava¹¹ÔìÁËÒ»¸ö¶þ²æÊ÷À࣬²¢´øÓвâÊÔµÄmain·½·¨£¬ÈçÓв»×ãÇë´ó¼Ò¶à¶àÖ¸½Ì¡£
/**
* ¶þ²æÊ÷¹¹ÔìËã·¨
* ¶þ²æÊ÷¶¨Ò壺ÊǶÈΪ2µÄÓÐÐòÊ÷£¬ËüµÄÌصãÊÇÿ¸ö½ÚµãÖÁ¶àÓÐÁ½¿Ã×ÓÊ÷
* ÎÒÃǵÄËã·¨¾ÍÊǸù¾Ý¶þ²æÊ÷µÄµÝ¹é¶¨Òå¶øÀ´£¬ÏÂÃæÊǶþ²æÊ÷µÄµÝ¹é¶¨Ò壺
* n(n>=0)¸ö½ÚµãµÄÓÐÏÞ¼¯¡£Ëü ......