jspÒ³Ãæ´«ÖµµÄÂÒÂëÎÊÌâµÄ½â¾ö
jspÒ³ÃæÖ®¼äµÄ´«ÖµÂÒÂëÎÊÌ⣬×ܽáÈçÏ£º
a.jspÍùb.jsp´«Öµ£º
a.jspÒ³ÃæÄÚÈÝ£º
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
name:<input type=text name=name>
<input type=submit>
</form>
b.jspÒ³ÃæÄÚÈÝ£º
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
String name=request.getParameter("name");
%>
<body>
<%=name%>
</body>
ÏÖÏó£ºÖÐÎÄÂÒÂë,±ÈÈç“£¿£¿£¿£¿£¿£¿”
½â¾ö·½·¨ÈçÏ£º
·½·¨Ò»£º
1. ÔÚb.jspÖаÑpageEncoding="GB2312"¸ÄΪpageEncoding="ISO8859-1"»òÕßÊÇpageEncoding="UTF-8 ",ËäÈ»ÕâÑùb.jspÒ³ÃæÏÔʾµÄÄÚÈÝ»¹ÊÇÂÒÂ룬µ«ÊDz»ÊÇÄÇÖÖ“£¿£¿£¿£¿£¿£¿”µÄÂÒÂ룬¶øÊÇһЩÌØÊâ×Ö·ûÈ»ºóÔÚä¯ÀÀÆ÷Öв鿴²Ëµ¥ÖÐÐ޸ijÉGB2312µÄ±àÂ룬ÕâʱÂÒÂë¾ÍÏÔʾÖÐÎÄÁË¡£µ«ÊÇÕâÖÖ·½·¨ÊDz»¿ÉÐеġ£
·½·¨¶þ£º
1. ÔÚb.jspÖаÑString name=request.getParameter("name");ÐÞ¸ÄΪ
String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"GB2312");
2. ÕâʱÔÙÔÚÒ³ÃæÉÏÏÔʾ£¬Ôò¾ÍÊÇÖÐÎÄÁË¡£µ«ÊDZàдÆðÀ´´úÂë·Ç³£·±Ëö£¬´ó¼Ò¶¼ÊDz»»áºÜϲ»¶µÄ¡£
·½·¨Èý£º
1. ÓÐÈË˵ÐÞ¸Äget/postµÄ´«Öµ·½Ê½,µ«ÊÇÕâÊÇÓÐÇ°ÌáµÄ,Èç¹ûÖ»ÊÇ°Ñget·½Ê½Ð޸ijÉpost·½Ê½,Ò³Ãæ½á¹û»¹ÊÇÂÒÂë!
2. Ç°ÌáÄã±ØÐëÅäÖÃÁ˹ýÂËÆ÷,Èô¹ûÄãÖ»ÊÇÅäÖÃÁ˹ýÂËÆ÷,Ôò´«Öµ·½Ê½±ØÐëÊÇ:post·½Ê½²Å²»ÊÇÂÒÂë,Èç¹ûÊÇget·½Ê½ÕÕÑùÊÇÂÒÂë!
3. ¹ýÂËÆ÷µÄÅäÖÃ,ÎÒÏë´ó¼Ò¶¼ÄÜÓÐ,ÎҾͲ»ËµÁË
·½·¨ËÄ:
1. ÓÐÈË˵ÅäÖÃtomcatµÄÅäÖÃÎļþserver.xmlÀïÕâ¾ä£º
<Connector URIEncoding="GB2312"
port="8080" maxHttpHeaderSize="8192"
&nbs
Ïà¹ØÎĵµ£º
JSPÄÚÖöÔÏó(9¸ö³£ÓõÄÄÚÖöÔÏó)
1.request¶ÔÏó
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
ÐòºÅ ·½ ·¨ ˵ Ã÷
1 object getAttribute(String name) ·µ»ØÖ¸¶¨ÊôÐÔµÄÊôÐÔÖµ
2 Enumeration getAttr ......
J2EE ̽Ë÷Õß:
´´½¨ºÍ¹ÜÀíÓÐ״̬ Web Ó¦ÓóÌÐò
¶Ô4ÖֻỰ×÷ÓÃÓòµÄÊʵ±´¦Àí
ÎĵµÑ¡Ïî
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
ÍØÕ¹ Tomcat Ó¦ÓÃ
......
ÏÈsunÌá³öµÄÊÇServletÌåϵ£¬Õâ¸öÌåϵʹµÃʹÓÃJAVAµÄ³ÌÐòÔ±Ò²ÄÜ¿ª·¢»ùÓÚB/S¼Ü¹¹µÄWEBÓ¦ÓóÌÐò£¬Ê¹ÓÃServletÀཫHTTPÇëÇóºÍÏìÓ¦·â×°ÔÚ±ê×¼JAVAÀàÖÐÀ´ÊµÏÖ¸÷ÖÖWEBÓ¦Ó÷½°¸¡£
Ëæ×Å´óÁ¿µÄB/S¼Ü¹¹³ÌÐò¿ª·¢³öÀ´ÒÔºó£¬ÈËÃÇ·¢ÏÖServletÀàµÄ±àдÊǷdz£·±ËöµÄ£¬Ö÷Òª¼¯ÖÐÔÚ¼¸¸öÎÊÌâÉÏ£ºÊ×ÏÈÓдóÁ¿ÈßÓà´úÂ룬ÕâЩ´úÂëÔÚÿ¸öservletÀàÖж ......
Çë²ÎÕÕÒÔϵÄÔ´úÂ룬עÒ⣺¿ÉÒÔÌæ»»JavaScriptÂëÖеÄ2007
ÒÔÏÂÊÇÍøÒ³Ô´´úÂë
<!-- ·ÖÈý²½Íê³ÉÈ«²¿½Å±¾:
1. ½«µÚÒ»²¿·ÖÕ³Ìùµ½HTMLµÄHEADÇø
2. ½«OnLoadʼþ¼ÓÈëBODY±êÇ©ÄÚ
3. ½«×îºóÒ»²¿·Ö´úÂë¼ÓÈëBODYÇø -->
<!-- µÚÒ»²½: ½«ÈçÏ´úÂëÕ³Ìùµ½HTMLµÄHEADÇø-->
<HEAD>
<SCRIPT LANGUAGE="JavaScri ......
Ò»£¬jsp³öÏֵĵÄÔÒò
¿´Á½¶Î´úÂëµÄ¶Ô±È
1 servletʵÏÖ
public class Welcome extends HttpServlet {
int num = 1;
public void doGet(HttpServletRequest request,
&nbs ......