Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : jsp

webʵÑ鱨¸æ——±íµ¥ÓëJSPÄÚÖöÔÏó

Ò»¡¢ÊµÑéÄ¿µÄ
1¡¢ ÕÆÎÕ±íµ¥µÄʹÓ÷½·¨£¬ÒÔ¼°·þÎñÆ÷¶Ë´¦Àí±íµ¥ÇëÇóµÄ·½·¨£»
2¡¢ Àí½âForwardµÄ×÷Óã»
3¡¢ ÊìÁ·ÔËÓÃJSPµÄµäÐÍÄÚÖöÔÏó
 
¶þ¡¢ÊµÑéÄÚÈݼ°²½Öè
1¡¢±íµ¥µÄʹÓü°ÆäµÝ½»¡¢´¦Àí¹ý³Ì
ÔÚÔ­´´½ÌÎñϵͳÖУ¬ÏµÍ³»á¸ù¾ÝÓû§ÀàÐÍ(½Ìʦ/ѧÉú)ÏÔʾ²»Í¬µÄÒ³Ã档ΪģÄâ¸Ã¹¦ÄÜ£¬ÐèÒª¶¨ÒåÉè¼ÆÈçÏÂÒ³Ã棺
-Login.html£º°üÀ¨Óû§ÀàÐÍÃû£¨Ä¬ÈÏΪѧÉúÀàÐÍ£©¡¢Óû§Ãû¡¢Óû§ÃÜÂë
Ô´´úÂ룺
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
    <title>Login.html</title>
   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=gbk">
   
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
 
 </head>
 
 <b ......

JSP×¢ÊÍ

½ñÌìÔÚµ÷ÊÔ´úÂëʱ£¬·¢ÏÖÒ»¶ÎдÔÚjsp¶ËµÄjava´úÂëÔõô±àÒ룬ÉèÖöϵ㶼²»»áÔڶϵ㴦ͣÁô¡£°Ù˼²»µÃÆä½â£¬ÔÚͬʵİïÖúÏ£¬·¢ÏÖÊÇ´úÂë×¢ÊÍÓÐÎÊÌâ¡£
      Ô­´úÂ룺
            <!-- <jsp:forward page="/hello/Welcome.do"/> -->
            <jsp:forward page="/login/UserLogin.do"/>
·¢ÏÖÔÚÕâÑùµÄÇé¿öÏ£¬Æäʵ³ÌÐòÖ´ÐеÄÊǵÚÒ»ÐдúÂ룬Òò´ËµÚ¶þÐдúÂë²»ÔÙÖ´ÐУ¬ËùÒÔÎ¥±³ÁËÎÒÃÇдµÄ´úÂëÒâͼ¡£
ÕýÈ·µÄjsp×¢ÊÍ£º
      £¨1£©¡¢<!-- comment -->
      ÕâЩÊÇÏÔʾעÊÍ£¬²»ÔÚÒ³ÃæÖÐÏÔʾ£¬µ«¿ÉÒÔÔÚ¿Í»§¶ËHTMLÔ´ÎļþÖп´µ½£¬»á±»JSPÒýÇæ½âÊÍ¡£
      ÀýÈ磺<!-- This page was loaded on <%= (new java.util.Date()).toLocaleString() %> -->
              ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖÐÏÔʾΪ: 
       ......

JSP URLÖÐÎÄ´«²Î

 ½«²ÎÊýд³É java.net.URLEncoder.encode(sContent,"gb2312")ºóÔÙ´«µÝ¡£
±ÈÈçurlÊÇ"/accept.do?content=<%=java.net.URLEncoder.encode(sContent,"UTF-8")%>";
¶Áȡʱ£¬Ê¹ÓÃ
String sc =  new String(request.getParameter("content").getBytes("iso-8859-1"),"UTF-8"); ......

jspÖÐÎÄÂÒÂëÎÊÌâ

Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.JSP)¾Í³öÏÖÂÒÂ룺
 
 
 
 
 
 
 
 
 
 
¶Ô²»Í¬µÄWEB·þÎñÆ÷ºÍ²»Í¬µÄJDK°æ±¾£¬´¦Àí½á¹û¾Í²»Ò»Ñù¡£Ô­Òò£º·þÎñÆ÷ʹÓõıàÂ뷽ʽ²»Í¬ºÍä¯ÀÀÆ÷¶Ô²»Í¬µÄ×Ö·ûÏÔʾ½á¹û²»Í¬¶øµ¼Öµġ£½â¾ö°ì·¨£ºÔÚJSPÒ³ÃæÖÐÖ¸¶¨±àÂ뷽ʽ(gb2312),¼´ÔÚÒ³ÃæµÄµÚÒ»ÐмÓÉÏ£º£¬¾Í¿ÉÒÔÏû³ýÂÒÂëÁË¡£ÍêÕûÒ³ÃæÈçÏ£º
 
 
 
 
 
 
 
 
 
 
 
 
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
ÏÂÃæÊÇÒ»¸öÌá½»Ò³Ãæ(submit.JSP)£¬´úÂëÈçÏ£º
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ÏÂÃæÊÇ´¦ÀíÒ³Ãæ(process.JSP)´úÂ룺
 
 
 
 
 
 
 
 
 
 
 
Èç¹ûsubmit.JSPÌá½»Ó¢ÎÄ×Ö·ûÄÜÕýÈ·ÏÔʾ£¬Èç¹ûÌá½»ÖÐÎÄʱ¾Í»á³öÏÖÂÒÂë¡£Ô­Òò£ºä¯ÀÀÆ÷ĬÈÏʹÓÃUTF-8±àÂ뷽ʽÀ´·¢ËÍÇëÇ󣬶øUTF-8ºÍGB2312±àÂ뷽ʽ±íʾ×Ö·ûʱ²»Ò»Ñù£¬ÕâÑù¾Í³öÏÖÁ˲»ÄÜʶ±ð×Ö·û¡£½â¾ö°ì· ......

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

1.           jspÒ³ÃæÏÔʾÖÐÎÄÂÒÂ룺
 
jspÒ³ÃæµÄ±àÂ뷽ʽÓÐÁ½¸öµØ·½ÐèÒªÉèÖãº
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
ÆäÖУºpageEncoding Ö¸µÄÊÇjspÎļþ±¾ÉíÔÚ±¾µØ±£´æʱµÄ±àÂ뷽ʽ¡£contentTypeµÄcharsetÊÇÖ¸·þÎñÆ÷·¢ËÍÍøÒ³ÄÚÈݸø¿Í»§¶ËʱËùʹÓõıàÂë¡£
´ÓµÚÒ»´Î·ÃÎÊÒ»¸öjspÒ³Ã濪ʼ£¬µ½Õâ¸öÒ³Ãæ±»·¢Ë͵½¿Í»§¶Ë£¬Õâ¸öJspÒ³ÃæÒª¾­¹ýÈý´Î±àÂëת»»£º
µÚÒ»½×¶ÎÊÇjsp±àÒë³É.java£¬Ëü»á¸ù¾ÝpageEncodingµÄÉ趨¶ÁÈ¡jsp£¬½á¹ûÊÇÓÉÖ¸¶¨µÄ±àÂë·½°¸·­Òë³ÉͳһµÄUTF-8 JAVAÔ´Â루¼´.java£©£¬Èç¹ûpageEncodingÉ趨´íÁË£¬»òûÓÐÉ趨£¬³öÀ´µÄ¾ÍÊÇÖÐÎÄÂÒÂë¡£
µÚ¶þ½×¶ÎÊÇÓÉJAVACµÄJAVAÔ´ÂëÖÁjava byteCodeµÄ±àÒ룬²»ÂÛJSP±àдʱºòÓõÄÊÇʲô±àÂë·½°¸£¬¾­¹ýÕâ¸ö½×¶ÎµÄ½á¹ûÈ«²¿ÊÇUTF-8µÄencodingµÄjavaÔ´Âë¡£
JAVACÓÃUTF-8µÄencoding¶ÁÈ¡javaÔ´Â룬±àÒë³ÉUTF-8 encodingµÄ¶þ½øÖÆÂ루¼´.class£©£¬ÕâÊÇJVM¶Ô³£Êý×Ö´®ÔÚ¶þ½øÖÆÂ루java encoding£©ÄÚ±í´ïµÄ¹æ·¶¡£
µÚÈý½×¶ÎÊÇTomcat£¨»òÆäµÄapplication container£©ÔØÈëºÍÖ´Ð ......

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

ÔÚactionÀïʹÓÃfileuploadʱ£¬´ÓreqeustµÃµ½µÄÖÐÎÄÊý¾ÝΪÂÒÂ룬³¢ÊÔʹÓÃÁË
Java´úÂë
1.   DiskFileItemFactory factory = new DiskFileItemFactory();  
    ServletFileUpload upload = new ServletFileUpload(factory);  
    upload.setHeaderEncoding("utf-8")  
 
2.jspÎļþµÄrequest.setCharacterEncoding("UTF-8");  
 
3.      FileItem item = (FileItem) itr.next();  
 
     String value = new String(item.getString().getBytes()) ;  
 
¾ùÎÞЧ£¡  
 
×îÖյĽâ¾ö°ì·¨ÊÇ Ê¹Óà org.apache.commons.fileupload×é¼þÀïµÄÒ»¸ö·½·¨:  
 
    String value = new String(item.getString("UTF-8") ......
×ܼǼÊý:884; ×ÜÒ³Êý:148; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [8] [9] [10] [11] 12 [13] [14] [15] [16] [17]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ