java elÅäÖúÍʹÓÃ
Ê×ÏÈÈ·¶¨ÓõÄServlet / JSPµÄ°æ±¾¡£
²é¿´web.xmlµÄ¿ªÍ·²¿·Ö£¬Èç¹ûÓÐÒÔÏÂÄÚÈÝ£¬±íʾÊÇServlet 2.4 / JSP 2.0¡£
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
ÔÚĬÈÏÇé¿öÏ£¬Servlet 2.4 / JSP 2.0Ö§³Ö¡£
Èç¹ûÊDZðµÄ°æ±¾Ï£¬½«Óõ½EL ±í´ïʽµÄ JSPÒ³ÃæµÄ¿ªÍ·Ìí¼ÓÈçÏÂÒ»¾ä´úÂë¼´¿É¡£
<%@ page isELIgnored="false" %> £¨Õâ¸öÎÒÊÔ¹ýÓÐÓã©
Ò»¡¢EL¼ò½é
1.Óï·¨½á¹¹
${expression}
2.[]Óë.ÔËËã·û
EL Ìṩ.ºÍ[]Á½ÖÖÔËËã·ûÀ´´æÈ¡Êý¾Ý¡£
µ±Òª´æÈ¡µÄÊôÐÔÃû³ÆÖаüº¬Ò»Ð©ÌØÊâ×Ö·û£¬Èç.»ò?µÈ²¢·Ç×Öĸ»òÊý×ֵķûºÅ£¬¾ÍÒ»¶¨ÒªÊ¹Óà []¡£ÀýÈ磺
${user.My-Name}Ó¦µ±¸ÄΪ${user["My-Name"] }
Èç¹ûÒª¶¯Ì¬È¡ÖµÊ±£¬¾Í¿ÉÒÔÓÃ[]À´×ö£¬¶ø.ÎÞ·¨×öµ½¶¯Ì¬È¡Öµ¡£ÀýÈ磺
${sessionScope.user[data]}ÖÐdata ÊÇÒ»¸ö±äÁ¿
3.±äÁ¿
EL´æÈ¡±äÁ¿Êý¾ÝµÄ·½·¨ºÜ¼òµ¥£¬ÀýÈ磺${username}¡£ËüµÄÒâ˼ÊÇÈ¡³öijһ·¶Î§ÖÐÃû³ÆΪusernameµÄ±äÁ¿¡£
ÒòΪÎÒÃDz¢Ã»ÓÐÖ¸¶¨ÄÄÒ»¸ö·¶Î§µÄusername£¬ËùÒÔËü»áÒÀÐò´ÓPage¡¢Request¡¢Session¡¢Application·¶Î§²éÕÒ¡£
¼ÙÈç;ÖÐÕÒµ½username£¬¾ÍÖ±½Ó»Ø´«£¬²»ÔÙ¼ÌÐøÕÒÏÂÈ¥£¬µ«ÊǼÙÈçÈ«²¿µÄ·¶Î§¶¼Ã»ÓÐÕÒµ½Ê±£¬¾Í»Ø´«null¡£
ÊôÐÔ·¶Î§ÔÚELÖеÄÃû³Æ
Page PageScope
Request RequestScope
Session SessionScope
Application ApplicationScope
¶þ¡¢ELÒþº¬¶ÔÏó
1.Ó뷶ΧÓйصÄÒþº¬¶ÔÏó
Ó뷶ΧÓйصÄEL Òþº¬¶ÔÏó°üº¬ÒÔÏÂËĸö£ºpageScope¡¢requestScope¡¢sessionScope ºÍapplicationScope£»
ËüÃÇ»ù±¾ÉϾͺÍJSPµÄpageContext¡¢request¡¢sessionºÍapplicationÒ»Ñù£»
ÔÚELÖУ¬ÕâËĸöÒþº¬¶ÔÏóÖ»ÄÜÓÃÀ´È¡µÃ·¶Î§ÊôÐÔÖµ£¬¼´getAttribute(String name)£¬È´²»ÄÜÈ¡µÃÆäËûÏà¹ØÐÅÏ¢¡£
ÀýÈ磺ÎÒÃÇҪȡµÃsessionÖд¢´æÒ»¸öÊôÐÔusernameµÄÖµ£¬¿ÉÒÔÀûÓÃÏÂÁз½·¨£º
session.getAttribute("username") È¡µÃusernameµÄÖµ£¬
ÔÚELÖÐÔòʹÓÃÏÂÁз½·¨
${sessionScope.username}
2.ÓëÊäÈëÓйصÄÒþº¬¶ÔÏó
ÓëÊäÈëÓйصÄÒþº¬¶ÔÏóÓÐÁ½¸ö£ºparamºÍparamValues£¬ËüÃÇÊÇELÖбȽÏÌرðµÄÒþº¬¶ÔÏó¡£
ÀýÈçÎÒÃÇҪȡµÃÓû§µÄÇëÇó²ÎÊýʱ£¬¿ÉÒÔÀûÓÃÏÂÁз½·¨£º
request.getParameter(String name)
request.getParameterValues(String
Ïà¹ØÎĵµ£º
¡¡¡¡Ëµµ½GB2312ºÍGBK¾Í²»µÃ²»ÌáÖÐÎÄÍøÒ³µÄ±àÂë¡£¾¡¹ÜºÜ¶àпª·¢µÄWebϵͳºÍÐÂÉÏÏßµÄ×¢Öعú¼Ê»¯µÄÍøÕ¾¶¼¿ªÊ¼Ê¹ÓÃUTF-8£¬ÈÔÓÐÏ൱һ²¿·ÖµÄÖÐÎÄýÌå¼á³ÖʹÓÃGB2312ºÍGBK£¬ÀýÈçÐÂÀ˵ÄÒ³Ãæ¡£ÆäÖÐÓÐÁ½µãºÜÖµµÃ×¢Òâ¡£
¡¡¡¡µÚÒ»£¬Ò³ÃæÖÐmeta±êÇ©µÄ²¿·Ö£¬³£³£¿ÉÒÔ¼ûµ½charset=GB2312ÕâÑùµÄд·¨£¬ºÜ²»ÐÒµÄÊÇ£¬Õâ¸ö“cha ......
JavaÖеÄ×Ö·û¼¯±àÂëÈëÃÅ
ASCII¼°Ïà¹Ø±ê×¼
¡¡¡¡µØÇòÈ˶¼ÖªµÀASCII¾ÍÊÇÃÀ¹ú±ê×¼ÐÅÏ¢½»»»ÂëµÄËõд£¬Ò²ÖªµÀASCII¹æ¶¨ÓÃ7λ¶þ½øÖÆÊý×ÖÀ´±íʾӢÎÄ×Ö·û£¬ASCII±»¶¨Îª¹ú¼Ê±ê×¼Ö®ºóµÄ ´úºÅΪISO-646.ÓÉÓÚASCIIÂëֻʹÓÃÁË7¸ö¶þ½øÖÆ룬Ҳ¾ÍÊÇ˵һ¸ö×Ö½Ú¿ÉÒÔ±íʾµÄ256¸öÊý×ÖÖУ¬Ëü½öʹÓÃÁË0-127Õâ128¸öÂëλ£¬Ê£Ï嵀 ......
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.huadoo.model.Area;
public class Aaaa {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
  ......
Ò»¡¢final
¸ù¾Ý³ÌÐòÉÏÏÂÎÄ»·¾³£¬Java¹Ø¼ü×ÖfinalÓГÕâÊÇÎÞ·¨¸Ä±äµÄ”»òÕß“ÖÕ̬µÄ”º¬Ò壬Ëü¿ÉÒÔÐÞÊηdzéÏóÀà¡¢·Ç³éÏóÀà³ÉÔ±·½·¨ºÍ±äÁ¿¡£Äã¿ÉÄܳöÓÚÁ½ÖÖÀí½â¶øÐèÒª×èÖ¹¸Ä±ä£ºÉè¼Æ»òЧÂÊ¡£
finalÀ಻Äܱ»¼Ì³Ð£ ......
java exception ½â¾ö·½°¸ - ÎÒµÄÒì³£Íø|Òì³£|exception 770 - java.net.unknownhostException 771 - com.ibatis.struts.BeanActionException 772 - javax.servlet.jsp.JspException:Cannot find bean under name org.apache.struts.taglib.html.BEAN 773 - java.lang.NoClassDefFoundError:org apache commons lang Unhand ......