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

JSP/ServletÖеıàÂëÏà¹ØÉèÖÃ

ÔÚJSPºÍServletÖÐÓм¸¸öµØ·½¶¼¿ÉÒÔÉèÖñàÂ룬¸÷¸ö±àÂëµÄ¹¦ÄÜÒ²²»Ò»Ñù£¬±¾ÎĽ«¶Ô¸÷¸ö±àÂë×öÒ»¸öС½á¡£
¸÷ÖÖ±àÂëÒ»ÀÀ
A. JSP/Servlet¶¼ÓеıàÂëÉèÖÃ
1. request.setCharacterEncoding("UTF-8")
2. response.setCharacterEncoding("UTF-8")
3. response.setContentType("text/html;
charset=UTF-8");
4. response.setHeader("Content-Type", "text/html; charset=UTF-8");
B. JSPרÓеıàÂëÉèÖÃ
1. <%@ pageEncoding="UTF-8" %>
2. <%@ contentType="text/html; charset=UTF-8" %>
C. HTMLÒ³ÃæÖеıàÂëÉèÖÃ
1. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
¡ùÒÔÏÂÄÚÈÝÓõ½±¾²¿·Ö±àÂëÉèÖÃʱ£¬½«Ê¹ÓÃA1, A3, B2µÄ·½Ê½¡£
ä¯ÀÀÆ÷ÈçºÎÈ·¶¨±àÂë¸ñʽÀ´ÏÔʾҳÃæ
web·þÎñÆ÷ÔÚ½ÓÊÕµ½ä¯ÀÀÆ÷µÄÇëÇóÐÅÏ¢ºó£¬¾­¹ý´¦Àí£¬»á·¢ËÍÒ»¸öÓ¦´ðÏûÏ¢¸øä¯ÀÀÆ÷¡£Ó¦´ðÏûÏ¢°üº¬Ò»°ãÈý¸ö²¿·Ö£º×´Ì¬ÐУ¬Ó¦´ðÊײ¿£¬Ó¦´ðÖ÷Ìå¡£ÏÂÃæÊÇÒ»¸öʾÀý£º
HTTP/1.0 200 OK
Last-Modified: Mon: 20 Dec 2001 23:26:42 GET
Date: Tue 11 Jan 2002 20:52:40 GMT
Status: 200
Content-Type: text/html; charset=UTF-8
Servlet-Engine: Tomcat Web Server/4.0.1
Content-Length: 59
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>
ÆäÖУ¬µÚÒ»ÐÐÊÇ״̬ÐУ¬×îºóµÄÒ»²¿·ÖÊÇÓ¦´ðÖ÷Ì壬¶øÖмäµÄ²¿·Ö¾ÍÊÇÓ¦´ðÊײ¿ÁË¡£¶øÓ¦´ðÖ÷Ì岿·ÖµÄContent-TypeÖеÄcharset¾ÍÖ¸¶¨ÁËä¯ÀÀÆ÷Ó¦¸Ã²ÉÓÃʲô±àÂë¸ñʽÀ´ÏÔʾҳÃæ¡£Èç¹ûûÓÐÖ¸¶¨charsetµÄ»°£¬ä¯ÀÀÆ÷»á¸ù¾ÝC1(metaÖеÄcharset)À´ÏÔʾҳÃ棻Èç¹ûC1ҲûÓеĻ°£¬¾Í²ÉÓñ¾µØĬÈϵıàÂë¸ñʽÏÔʾҳÃ棨Ӧ¸ÃÓë¿Í»§¶ËµÄ²Ù×÷ϵͳÓйأ©
¡ïä¯ÀÀÆ÷ÏÔʾҳÃæËùÓõĸñʽ¿ÉÒÔͨ¹ý²Ëµ¥ -> ²é¿´ -> ±àÂëÀ´²é¿´¾ßÌåÊÇÄÄÖÖ±àÂë¸ñʽ
web·þÎñÆ÷ÈçºÎ¾ö¶¨±àÂë
´ÓÉÏÃæ¿ÉÒÔÖªµÀ£¬·þÎñÆ÷ÔÚ·¢Ë͸ø¿Í»§¶ËµÄÓ¦´ðÖ÷ÌåÖÐÒ»°ã»á°üº¬charset¡£¶øÕâ¸öcharsetµÄÖµÓм¸¸öÀ´Ô´£¬ÎÒÃÇ´Ó¸ßÓÅÏȼ¶µ½µÍÓÅÏȼ¶ÅÅÁС£
×¢£ºÏÂÃæµÄ½áÂÛÊDzÉÓÃTomcat 5.5È·ÈϵĽáÂÛ£¬²»Ò»¶¨È«²¿ÊÊÓÃÓÚÆäËû·þÎñÆ÷¡£
1. A2, A3, A4
Èç¹ûÄãµÄJSP»òÕßServletÖаüº¬ÒÔÉÏ3ÖÐÀàÐ͵ĴúÂ룬ÄÇôcharset¾ÍÊÇËüÃÇ¡£Èç¹ûÓжàÌõÓï¾äÉèÖã¬ÄÇôcharset¾ÍÊÇ×îºóÒ»ÌõËùÉèÖõÄÖµ¡£
2. B2
B2µÄ´úÂëÔÚ±àÒë³Éclass


Ïà¹ØÎĵµ£º

ServletÓëJSPÖÐÒ³ÃæÌøתµÄÇø±ð

Ò»Ö±¶ÔServletµÄ¼¸ÖÖÒ³ÃæÌøת·½Ê½£¬Àí½âµÄºýÀïºýÍ¿µÄ£¬½ñÌìÔÚÍøÉÏËÑÁËÒ»°Ñ£¬ÕÒµ½Ò»±é±È½ÏºÃµÄ£¬¼ÇÏÂÀ´£¬ÒÔºó¿´¿´¡£
  Ìøת·ÖÁ½²¿·Ö£¬Ò»ÊÇ·¢ÉúÔÚservlet£¬Ò»ÊÇÔÚJSP£¬ÆäʵJSPÒ²¾ÍÊÇservlet£¬²»¹ý»¹ÊÇÓеã²îÒìµÎ¡£
Servlet£º
µ±È»£¬ÔÚservletÖУ¬Ò»°ãÌøת¶¼·¢ÉúÔÚdoGet, doPostµÈ·½·¨ÀïÃæ¡£
1)  redirect · ......

JSPÄÚ²¿¶ÔÏóÏê½â

1¡¢Out¶ÔÏó
Ö÷ÒªÓÃÀ´Ïò¿Í»§¶ËÊä³ö¸÷ÖÖ¸ñʽµÄÊý¾Ý£¬²¢ÇÒ¹ÜÀíÓ¦Ó÷þÎñÆ÷ÉϵÄÊä³ö»º³åÇø£¬Out¶ÔÏóµÄ»ùÀàÊÇjavax.servlet.jsp.JspWriterÀà¡£
OutµÄÖ÷Òª·½·¨£º
out.println(DataType);»òout.print(DataType);
ʵÀý£º
<%@page language="java"
contentType="text/html;charset=gb2312"
import="java.util.*"
%>
&l ......

jsp Session¹ÜÀí(ThreadLocal)

ÔÚ¸÷ÖÖSession ¹ÜÀí·½°¸ÖУ¬ ThreadLocal ģʽµÃµ½ÁË´óÁ¿Ê¹Óá£ThreadLocal ÊÇ
JavaÖÐÒ»ÖÖ½ÏΪÌØÊâµÄḬ̈߳󶨻úÖÆ¡£Í¨¹ýThreadLocal´æÈ¡µÄÊý¾Ý£¬×ÜÊÇÓ뵱ǰÏß³ÌÏà¹Ø£¬
Ò²¾ÍÊÇ˵£¬JVM Ϊÿ¸öÔËÐеÄỊ̈߳¬°ó¶¨ÁË˽Óеı¾µØʵÀý´æÈ¡¿Õ¼ä£¬´Ó¶øΪ¶àÏ̻߳·¾³³£³ö
ÏֵIJ¢·¢·ÃÎÊÎÊÌâÌṩÁËÒ»ÖÖ¸ôÀë»úÖÆ¡£
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÖªµÀ£¬ ......

oracleÖÐClob×Ö¶ÎÖеĻسµ»»ÐÐÔÚjspÖÐչʾµÄÎÊÌâ

ÔÚ¿ª·¢¹ý³Ì³öÏÖÕâôһ¸öÎÊÌ⣺
   ±ÈÈ磺һ¸ö×Ö¶Îcontent ÀàÐÍCLOB£¬ÕâÆäÖдæµÄÓпÉÄܸ´ÖÆÕ³Ìù¹ýÀ´µÄword excel htmlÖеÄÄÚÈÝ£¬ÓÃjava½«ÕâЩÄÚÈÝ´æÈ룬´æÈëºóÓÐÌØÊâµÄ·ûºÅ ±ÈÈç»Ø³µ»»Ðеȡ£ÄÇô²»ÄÜÕý³£Õ¹Ê¾µÄÊý¾Ý¡£
   ½â¾ö·½°¸£º
   ´æÈëÊý¾ÝµÄÊǽ«Õâ¸öÊý¾ÝcontentdataÔÚjsÖнøÐÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ