jsp ÂÒÂëÎÊÌâ
a.jspÒ³ÃæÄÚÈÝ£º
%26lt;%@ page language£½"java" import£½"java.util." pageEncoding£½"GB2312"%%26gt;%26lt;form action£½"b.jsp"%26gt; name£º%26lt;input type£½text name£½name%26gt; %26lt;input type£½submit%26gt;%26lt;/form%26gt;
b.jspÒ³ÃæÄÚÈÝ£º
%26lt;%@ page language£½"java" import£½"java.util." pageEncoding£½"GB2312"%%26gt;%26lt;% String name£½request.getParameter£¨"name"£©;%%26gt;%26lt;body%26gt; %26lt;%£½name%%26gt;%26lt;/body%26gt;
ÏÖÏó£ºÖÐÎÄÂÒÂ룬±ÈÈç“£¿£¿£¿£¿£¿£¿”
½â¾ö·½·¨ÈçÏ£º
·½·¨Ò»£º
1. ÔÚb.jspÖаÑpageEncoding£½"GB2312"¸ÄΪpageEncoding£½"ISO8859£1"
ËäÈ»ÕâÑùb.jspÒ³ÃæÏÔʾµÄÄÚÈÝ»¹ÊÇÂÒÂ룬µ«ÊDz»ÊÇÄÇÖÖ“£¿£¿£¿£¿£¿£¿”µÄÂÒÂ룬¶øÊÇһЩÌØÊâ×Ö·û
2. È»ºóÔÚä¯ÀÀÆ÷Öв鿴²Ëµ¥ÖÐÐ޸ijÉGB2312µÄ±àÂ룬ÕâʱÂÒÂë¾ÍÏÔʾÖÐÎÄÁË¡£
3. µ«ÊÇÕâÖÖ·½·¨ÊDz»¿ÉÐеġ£
·½·¨¶þ£º
1. ÔÚb.jspÖаÑString name£½request.getParameter£¨"name"£©;ÐÞ¸ÄΪ
String name£½new String£¨request.getParameter£¨"name"£©.getBytes£¨"ISO£8859£1"£©£¬"GB2312"£©;
2. ÕâʱÔÙÔÚÒ³ÃæÉÏÏÔʾ£¬Ôò¾ÍÊÇÖÐÎÄÁË¡£
·½·¨Èý£º
1. ÓÐÈË˵ÐÞ¸Äget/postµÄ´«Öµ·½Ê½£¬µ«ÊÇÕâÊÇÓÐÇ°ÌáµÄ£¬Èç¹ûÖ»ÊÇ°Ñget·½Ê½Ð޸ijÉpost·½Ê½£¬Ò³Ãæ½á¹û»¹ÊÇÂÒÂ룡
2. Ç°ÌáÄã±ØÐëÅäÖÃÁ˹ýÂËÆ÷£¬Èô¹ûÄãÖ»ÊÇÅäÖÃÁ˹ýÂËÆ÷£¬Ôò´«Öµ·½Ê½±ØÐëÊÇ£ºpost·½Ê½²Å²»ÊÇÂÒÂ룬Èç¹ûÊÇget·½Ê½ÕÕÑùÊÇÂÒÂ룡
3. ¹ýÂËÆ÷µÄÅäÖã¬ÎÒÏë´ó¼Ò¶¼ÄÜÓУ¬ÎҾͲ»ËµÁË
·½·¨ËÄ£º
1. ÓÐÈË˵ÅäÖÃtomcatµÄÅäÖÃÎļþserver.xmlÀïÕâ¾ä£º
%26lt;Connector URIEncoding£½"GB2312" port£½"8080" maxHttpHeaderSize£½"8192" maxThreads£½"150" minSpareThreads£½"25" maxSpareThreads£½"75" enableLookups£½"false" redirectPort£½"8443" acceptCount£½"100" connectionTimeout£½"20000" disableUploadTimeout£½"true" /%26gt;
¼ÓÉÏÕâ¾ä£ºURIEncoding£½"GB2312"
2. ËäÈ»¿ÉÒÔµ«ÊÇÓÐÇ°ÌáµÄ£¬Èô¹ûÄã¹ýÂËÆ÷ûÓÐÅäÖã¬ÔòÖ»ÊÇÅäÖÃÁËserver.xmlÎļþ£¬ÕâÑùÖ»ÓÐÔÚ±íµ¥ÊÇget´«ÖµÊ±ºò²Å¿ÉÒÔ£¡µ±ÊÇpost·½Ê½Ê±£¬ÕÕÑùÊÇÂÒÂ룡
ÕâʱÎÒÃǾͿÉÒÔ¿´³öÔÚtomcat5ÖеÄpostÓëget´«Öµ·½Ê½ÊDz»Ò»ÑùµÄ
ÓÐÈËÒªÎÊÓÐûÓÐÒ»ÖÖ·½·¨Èô«ÖµÊ¹ÓÃget·½Ê½»òpost·½Ê½¶¼ºÃÓÃÄØ£¬ÏÂÃæ¾ÍÊÇÎÒÍƼöµÄ·½·¨Îå
·½·¨Î壺
1. ÆäʵºÜ¼òµ¥£¬¾ÍÊÇͬʱʵÏÖ·½·¨ÈýÓÖʵÏÖ·½·¨ËÄ£¡
2. ¾ÍÊÇÏ
Ïà¹ØÎĵµ£º
¼òµ¥Ê¾Àý
JSPÒ³ÃæÖУ¬ÎÒÃǾ³£ÓÐÒýÓø÷ÖÖͼƬµÈ×ÊÔ´£¬ÀýÈçÏÂÃæµÄjspƬ¶ÎÖÐ
<div class="main">
<a href="http://www.sina.com.cn/abc.htm">
<strong>Îҵĵµ°¸</strong>
&nbs ......
²»ÒªÔÚJSPÖд¦ÀíÓû§ÇëÇó£¨request£©£¬Ò²²»ÒªÔÚJSPÖÐǶÈë¿ØÖÆÁ÷´úÂë
²»Òª½«Óû§½çÃ沿·ÖºÍÒµÎñÂß¼²¿·Ö»ìºÏ
ÔÚJSPÖо¡Á¿²»Òª°üº¬java´úÂ룬ELÔÚÕâ·½Ãæ¿ÉÒÔ¸øÎÒÃǺܴó°ïÖú
½«Ò³Ãæ·ÖΪ¼¸¸ö²¿·Ö£ºHeader£¬Menu£¬Main¡£¡£¡£
......
ѧϰËÑË÷ÒýÇ棬£¬·¢¾õjspµ÷ÓÃjava´óÖÂÓÐ3ÖÖ·½·¨¡£
µÚÒ»ÖÖ£¬Ê¹ÓÃjavabean¡£ÀýÈç
<jsp:useBean id="mm" class="com.ReadComm" scope="page"> </jsp:useBean>
classÖÐÌîдclass·¾¶¡£
µÚ¶þÖÖ£¬Ö±½ÓimportÒýÓÃjavaÀà
±ÈÈ磺 <%@ page import="java.util.*"%>
°ÑÄãµÄÀà·Åµ½WEB-INF\classesÏ£¬ÒýµÃʱ ......
½â¾ö°ì·¨£º
µÚÒ»£º
1:ÔÚjspÒ³Ãæ¼ÓÈ룺
<%@ page contentType="text/html; charset=gb2312" %>
2:ÔÚservletÀïÃæ:
public void doGet(HttpServletRequest request, HttpServletResponse &nbs ......
ÐèÒª¼ÇסµÄ֪ʶµã£º
1 ÇëÇóÓ¦´ðģʽ£¬¿Í»§¶Ë·¢ËÍÇëÇ󣬷þÎñÆ÷½øÐÐÏìÓ¦
2 JSPÎļþÊÇÔÚ·þÎñÆ÷¶ËÖ´ÐеÄ
3 ·µ»Ø¸ø¿Í»§¶ËµÄ½á¹ûÊÇJSPÎļþÖ´ÐеĽá¹û£¬²»°üº¬ÈκÎJSPÓï·¨
4 ÄÚ²¿¶ÔÏóÊÇÔÚ°ÑJSPÎļþת»»ÎªJava´úÂëµÄʱºòÉú³ÉµÄ
5 Ö´ÐеIJ¢²»ÊÇJSPÎļþ±¾Éí£¬¶øÊÇJSPת»»³ÉµÄJavaÀàµÄ¶ÔÏóµÄ·½·¨£¬ËùÒÔÓÐʱºòÐÞ¸ÄJSPÎļþ² ......