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

Jsp /jsÂÒÂëÎÊÌâ


1£®
×î»ù±¾µÄÂÒÂëÎÊÌâ¡£
Õâ¸öÂÒÂëÎÊÌâÊÇ×î¼òµ¥µÄÂÒÂëÎÊÌâ¡£Ò»°ãÐÂÊÖ»á³öÏÖ¡£¾ÍÊÇ
Ò³Ãæ±àÂë²»Ò»Öµ¼ÖµÄÂÒÂë¡£
<%@ page
language="java" pageEncoding="UTF-8"%>
<%@ page
contentType="text/html;charset=iso8859-1"%>
<html>
<head>
<title>ÖÐÎÄÎÊÌâ</title>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
</head>
<body>
ÎÒÊǸöºÃÈË
</body>
</html>
Èý¸öµØ·½µÄ±àÂ룺
£¨£±£©
µÚÒ»¸öµØ·½µÄ±àÂë¸ñʽΪjspÎļþµÄ´æ´¢¸ñʽ¡£Eclipse»á¸ù¾ÝÕâ¸ö±àÂë¸ñʽ±£´æÎļþ¡£²¢±àÒëjspÎļþ£¬°üÀ¨ÀïÃæµÄºº×Ö¡£
£¨£²£©µÚ¶þ´¦±àÂëΪ½âÂë¸ñʽ¡£ÒòΪ´æΪUTF-8µÄÎļþ±»½âÂëΪiso8859-1£¬ÕâÑùÈçÓÐÖÐÎĿ϶¨³öÂÒÂë¡£Ò²¾ÍÊÇ
±ØÐëÒ»Ö¡£¶øµÚ¶þ´¦ËùÔÚµÄÕâÒ»ÐУ¬¿ÉÒÔûÓС£È±Ê¡Ò²ÊÇʹÓÃiso8859-1µÄ±àÂë¸ñʽ¡£ËùÒÔÈç¹ûûÓÐÕâÒ»ÐеĻ°£¬“ÎÒÊǸöºÃÈ˔Ҳ»á³öÏÖÂÒÂë¡£±ØÐëÒ»ÖÂ
²Å¿ÉÒÔ¡£
£¨£³£©µÚÈý´¦±àÂëΪ¿ØÖÆä¯ÀÀÆ÷µÄ½âÂ뷽ʽ¡£Èç¹ûÇ°ÃæµÄ½âÂ붼һÖ²¢
ÇÒÎÞÎóµÄ»°£¬Õâ¸ö±àÂë¸ñʽûÓйØϵ¡£ÓеÄÍøÒ³³öÏÖÂÒÂ룬¾ÍÊÇÒòΪä¯ÀÀÆ÷²»ÄÜÈ·¶¨Ê¹ÓÃÄÄÖÖ±àÂë¸ñʽ¡£ÒòΪҳÃæÓÐʱºò»áǶÈëÒ³Ã棬µ¼ÖÂä¯ÀÀÆ÷»ìÏýÁ˱àÂë¸ñʽ¡£
³öÏÖÁËÂÒÂë¡£
2£® ±íµ¥Ê¹ÓÃPost·½Ê½Ìá½»ºó½ÓÊÕµ½µÄÂÒÂëÎÊÌâ
Õâ¸öÎÊÌâÒ²ÊÇÒ»¸ö³£¼ûµÄÎÊÌâ¡£Õâ¸öÂÒÂëÒ²ÊÇtomcatµÄÄÚ²¿±àÂë¸ñʽiso8859-1ÔÚµ·ÂÒ£¬
Ò²¾ÍÊÇ˵postÌύʱ£¬Èç¹ûûÓÐÉèÖÃÌá½»µÄ±àÂë¸ñʽ£¬Ôò»áÒÔiso8859-1·½Ê½½øÐÐÌá½»£¬½ÓÊܵÄjsp£¨´ÓjspÌøתµ½ÁíÒ»¸öjsp£©È´ÒÔutf-
8µÄ·½Ê½½ÓÊÜ¡£µ¼ÖÂÂÒÂë¡£¼ÈÈ»ÕâÑùµÄÔ­Òò£¬ÏÂÃæÓм¸ÖÖ½â¾ö·½Ê½¡£
£¨£±£© ½Ó
ÊܲÎÊýʱ½øÐбàÂëת»»
String str = new
String(request.getParameter("something").getBytes("ISO-8859-1"),"utf-
8")£» ÕâÑùµÄ»°£¬Ã¿Ò»¸ö²ÎÊý¶¼±ØÐëÕâÑù½øÐÐתÂë¡£ºÜÂé·³¡£µ«È·Êµ¿ÉÒÔÄõ½ºº×Ö¡£
£¨£²£©ÔÚÇëÇóÒ³ÃæÉÏ¿ªÊ¼´¦£¬Ö´ÐÐÇëÇóµÄ±àÂë´úÂ룬
request.setCharacterEncoding("UTF-8")£¬°ÑÌá½»ÄÚÈݵÄ×Ö·û¼¯ÉèΪUTF£­8¡£ÕâÑùµÄ»°£¬½ÓÊܴ˲ÎÊýµÄÒ³Ãæ¾Í²»±ØÔÚ
תÂëÁË¡£Ö±½ÓʹÓÃString str =
request.getParameter("something")£»¼´¿ÉµÃµ½ºº×Ö²ÎÊý¡£µ«Ã¿Ò³¶¼ÐèÒªÖ´ÐÐÕâ¾ä»°¡£
×¢Ò⣺
Õâ¸ö·½·¨Ò²¾Í¶ÔpostÌá½»µÄÓÐЧ¹û£¬¶ÔÓÚgetÌá½»ºÍÉÏ´«


Ïà¹ØÎĵµ£º

JSP Ò³Ã滺´æÒÔ¼°Çå³ý»º´æ

Ò»¡¢¸ÅÊö
    »º´æµÄ˼Ïë¿ÉÒÔÓ¦ÓÃÔÚÈí¼þ·Ö²ãµÄ¸÷¸ö²ãÃæ¡£ËüÊÇÒ»ÖÖÄÚ²¿»úÖÆ£¬¶ÔÍâ½ç¶øÑÔ£¬ÊDz»¿É¸ÐÖªµÄ¡£
    Êý¾Ý¿â±¾ÉíÓлº´æ£¬³Ö¾Ã²ãÒ²¿ÉÒÔ»º´æ¡££¨±ÈÈ磺hibernate£¬»¹·Ö1¼¶ºÍ2¼¶»º´æ£©
    ÒµÎñ²ãÒ²¿ÉÒÔÓлº´æ£¨µ«Ò»°ãÀ´Ëµ£¬ÕâÊÇÒ»¸ö¹ý³ÌÓò£¬²»»áÉ軺´æ£©¡£
&nbs ......

jspºÍServletÖÐÎÄÂÒÂë»ã×Ü

1.           jspÒ³ÃæÏÔʾÖÐÎÄÂÒÂ룺
 
jspÒ³ÃæµÄ±àÂ뷽ʽÓÐÁ½¸öµØ·½ÐèÒªÉèÖãº
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
ÆäÖУºpageEncoding Ö¸µÄÊÇjspÎļþ±¾É ......

Jsp apache common fileupload ÎļþÉÏ´« ÂÒÂë

ÔÚactionÀïʹÓÃfileuploadʱ£¬´ÓreqeustµÃµ½µÄÖÐÎÄÊý¾ÝΪÂÒÂ룬³¢ÊÔʹÓÃÁË
Java´úÂë
1.   DiskFileItemFactory factory = new DiskFileItemFactory();  
    ServletFileUpload upload = new ServletFileUpload(factory);  
    upload.setHeaderEnco ......

Ëѹ·Ë«ºËµÄJSP sessionÎÊÌâ

Ëѹ·Ë«ºËä¯ÀÀÆ÷³öÀ´Ö®ºó£¬ÎÒ¾ÍÓÃËüÀ´µ÷ÊÔÒ³Ã棬°´Ò»¸ö°´Å¥¿ÉÒÔÇл»Á½ÖÖä¯ÀÀÆ÷ÒÔ¹Û²ìÍøҳЧ¹û£¬»¹ÊDZȽϷ½±ãµÄ£¬µ«ÊÇ×î½ü·¢ÏÖËѹ·µÄJSP sessionòËƳöÏÖÎÊÌâ¡£»¹ÔÚ²âÊÔÖУ¬×î½üÒ»Á½Ìì»áд³öÒ»¸ö±È½ÏÏêϸµÄ²âÊÔ±¨¸æ¡£°¥£¬ÄѵÀÊÇÎÒµÄsessionдµÄÓÐÎÊÌ⣿ÔõôÔÚÍøÉÏËѲ»µ½ÀàËƵĶ«Î÷... ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ