java ¹ýÂËÆ÷£¨²ÎÊý´«µÝÖÐÎÄÂÒÂ룩
(Ò»)¹ýÂËÆ÷Àà±àд¡£
1¡¢ÉèÖÃ×Ö·û¼¯±àÂ뷽ʽ£º
±àд¹ýÂËÆ÷ÀࣺʵÏÖ½Ó¿Újavax.servlet.Filter
public class CharacterEncodingFilter implements Filter {
private String charset;
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding(charset);
filterChain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException {
// TODO Auto-generated method stub
charset = config.getInitParameter("charset");
}
}
ÒÔÉϹýÂËÆ÷ÀàÖ»Äܱ£Ö¤postÌá½»·½Ê½ÄÜÕýÈ·½âÂë¡£get·½Ê½ÒÀÈ»»á³öÎÊÌâ¡£
String username = new String(request.getParamter("userName").getBytes("ISO8859-1"),"GBK")
´Ë·½·¨ÔÚ½ÓÊÜÒ³ÃæÉÏÄܹ»¶ÔpostºÍgetÁ½ÖÖ·½Ê½´«¹ýÀ´µÄ²ÎÊýuserName½øÐÐÕýÈ·ÏÔʾ£¬µ«Ã¿¸ö²ÎÊý¶¼Ê¹ÓÃÕâÖÖ·½Ê½
À´½ÓÊÜ»áÌ«Âé·³£¬ËùÒÔ»¹ÊÇʹÓùýÂËÆ÷µÄ·½Ê½±È½Ï·½±ã¡£
¶ÔÓÚget½ÓÊܲÎÊýµÄ½â¾ö·½·¨£ºÐ޸ķþÎñÆ÷µÄÅäÖÃÎļþÖÐ
ÐÞ¸Ãtomcat·þÎñÆ÷µÄ°²×°Ä¿Â¼£¨E:\Program Files\Apache Software Foundation\Tomcat 6.0\conf£©ÏµÄserver.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
Ìí¼ÓÊôÐÔ URIEncoding="GBK" £¬´Ë·½Ê½Ö»Äܽâ¾öget·½Ê½Ìá½»¡£
2¡¢¼ì²âÓû§ÊÇ·ñµÇ½µÄ¹ýÂËÆ÷
public class CheckLoginFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest hsRequest = (HttpServletRequest)request;
HttpServletResponse hsResponse = (HttpServletResponse)response;
HttpSession session = hsRequest.getSession();
//ûµÇ¼
if(session.getAttribute("userID") == null)
{
String uri = hsRequest.getRequestURI();
// ÇëÇóµ
Ïà¹ØÎĵµ£º
1.ΪʲôҪʹÓÃÏ̳߳Ø
ÔÚjavaÖУ¬Èç¹ûÿ¸öÇëÇóµ½´ï¾Í´´½¨Ò»¸öÐÂỊ̈߳¬¿ªÏúÊÇÏ൱´óµÄ¡£ÔÚʵ¼ÊʹÓÃÖУ¬·þÎñÆ÷ÔÚ´´½¨ºÍÏú»ÙÏß³ÌÉÏ»¨·ÑµÄʱ¼äºÍÏûºÄµÄϵͳ×ÊÔ´¶¼Ï൱´ó£¬ÉõÖÁ¿ÉÄÜÒª±ÈÔÚ´¦Àíʵ¼ÊµÄÓû§ÇëÇóµÄʱ¼äºÍ×ÊÔ´Òª¶àµÄ¶à¡£³ýÁË´´½¨ºÍÏú»ÙÏ̵߳ĿªÏúÖ®Í⣬»î¶¯µÄÏß³ÌÒ²ÐèÒªÏûºÄϵͳ×ÊÔ´¡ ......
ÔÚEclipseÖÐÎÒÃǾ³£»áÏòÖ÷·½·¨×¢Èë²ÎÊý£¬ÒÔÌṩ¸ø³ÌÐòµÄÔËÐУ¬Æä·½·¨ÈçÏ£º
1.µãÔËÐа´Å¥£¨»òÓÒ»÷ÒªÔËÐеÄÀࣩ
2.µã»÷Open Run Dialog..
3.Ñ¡ÖÐ×ó²àÐèÒªÔËÐеÄÀà
4.ÔÚÓÒ²àÑ¡ÖÐArgument
5.ÔÚProgram ArgumentÖÐÊäÈëÄãҪעÈëµ½Ö÷º¯ÊýÖеIJÎÊý
6.µã»÷ÔËÐУ¨Run£©£¬¾Í¿ÉÒÔÔËÐÐÁË¡£¡£¡£ ......
×î½üÔÚдjava²âÊÔ³ÌÐòµÄʱºòͻȻÓöµ½ÁËÒ»¸öÎÊÌ⣺javaĬÈÏ°üÖеÄpublicÀàÊDz»ÄÜÔÚÆäËû°üÖÐÖ±½Óµ÷ÓõÄ
Ê×ÏÈ£¬×ܽáÒ»ÏÂĬÈÏ°üÖÐÀàµÄʹÓ÷¶Î§£¬javaĬÈÏ°üÖеÄÀà¿ÉÒÔʵÀý»¯ÆäËü°üÖеÄpublicÀ࣬µ«ÊÇÆäËü°üÖеÄÀàÊDz»ÄÜÏÔʽʵÀý»¯Ä¬ÈÏ°üÖеÄÀàÕâ¸öÌØÐÔÔÚJDK1.4ÒÔºóµÄ°æ±¾³ÉÁ¢£»
& ......
ÔÚJavaÖУ¬²»Í¬µÄÀ඼ÓÐ×Ô¼ºµ¥¶ÀµÄCache»úÖÆ£¬ÊµÏֵķ½·¨Ò²¿ÉÄÜÓÐËù²»Í¬£¬ÎÄÕÂÁоÙÁËJavaÖг£¼ûµÄ¸÷ÀàCache»úÖƵÄʵÏÖ·½·¨£¬Í¬Ê±½øÐÐÁË×ۺϵıȽϡ£
OSCache
OSCacheÊǸöÒ»¸ö¹ã·º²ÉÓõĸßÐÔÄܵÄJava EE»º´æ¿ò¼Ü£¬OSCacheÄÜÓÃÓÚÈκÎJavaÓ¦ÓóÌÐòµÄÆÕͨµÄ»º´æ½â¾ö·½°¸¡£
OSCacheÓÐÒÔÏÂÌص㣺»º´æÈκζÔÏó£¬Äã¿ÉÒÔ²»ÊÜÏÞÖƵ ......
1.¶ÔcollectionsµÄÖ§³Ö
Java´úÂë
List<String> list = new ArrayList<String>();
list.add("item");
String item = list.get(0);
Set<String> set = new HashSet<String>(); &nb ......