Jsp»ù±¾Óï·¨
ÍøÂçÈí¼þ¿ª·¢ÖÐ×î³£ÓõÄÁ½ÖÖ¼ÆËãģʽ£¬Ò²¾ÍÊÇÍøÂç³ÌÐòģʽ£º
B/SÊÇ ä¯ÀÀÆ÷/·þÎñÆ÷ ģʽ£¬Ö»ÒªÔÚ·þÎñÆ÷×°ºÃºó£¬ÆäËûÈËÖ»ÐèÒªÓÃä¯ÀÀÆ÷£¨±ÈÈçIE£©¾Í¿ÉÒÔÕý³£ä¯ÀÀ£»ÈçÍøÒ³ÓÎÏ·£¬¿ªÐÄÍøµÈ¡£
C/SÊÇ ¿Í»§¶Ë/·þÎñ¶Ë ģʽ£¬·þÎñÆ÷×°ºÃºó£¬ÆäËûÈË»¹ÐèÒªÔÚ¿Í»§¶ËµÄµçÄÔÉÏ°²×°×¨ÓõĿͻ§¶ËÈí¼þ²ÅÄÜÕý³£ä¯ÀÀ²Ù×÷£¬ÈçQQ£¬Ä§ÊÞÊÀ½çµÈ¡£
JSP:JSP´úÂëÖ¸µÄÊÇǶÈëÔÚJSPÒ³ÃæÖеÄJava´úÂë.
ÔÚHTMLÖмÓÈëjava³ÌÐòƬ¾Í³ÉÁËJSPÒ³Ãæ³ÌÐò¡£
¹ÊJSP°üº¬Á½¸öÄÚÈÝ£ºHTMLºÍjava³ÌÐò¼°ÆäÏà¹ØÔªËØ£»
ÆäÖУ¬java³ÌÐò¼°ÆäÏà¹ØÔªËØ°üÀ¨£ºjava³ÌÐòƬ£¬±í´ïʽ£¬JSPÖ¸Áî·ûÓ붯×÷ÔªËØ£¬java±äÁ¿£¬·½·¨ºÍÀàµÄÉùÃ÷¡£
±ê¼Ç£º
Ö¸Áî±ê¼Ç<%@ %>
java³ÌÐòƬ£¨´úÂëƬ¶Î£©±ê¼Ç£¬ÄÚ²¿Ç¶Ì×java´úÂë<% %>
±í´ïʽ±ê¼Ç<%= %>£¬×¢Òâ±í´ïʽ±ê¼ÇÀïÃæ²»ÄܼӷֺÅ!¶ø´úÂëƬ¶Î±ê¼Ç±ØÐë¼Ó·ÖºÅ¡£
jspËĸö·¶Î§(±ØÐëŪ¶®)£º
page Ò³Ã漶±ð
request ÇëÇ󼶱ð£¨×î³£Óã©Ó¦ÓÃÓÚ·þÎñÆ÷Ìøת(ÈÝÆ÷ÄÚµÄÌøת),Ò»´ÎÇëÇó
session »á»°¼¶±ð£¨×î³£Ó㩼ȿÉÒÔÓ¦ÓÃÓÚ·þÎñÆ÷Ìøת£¬Ò²¿ÉÒÔÓ¦ÓÃÓÚ¿Í»§¶ËÌøת¡£
application Ó¦Óü¶±ð
·þÎñÆ÷¶ËÌøת£º
·þÎñÆ÷ÊÇÈÝÆ÷ÄÚÌøת£¬ÕâÖÖÌøת¶ÔÓÚ¿Í»§¶ËÊÇ͸Ã÷µÄ¡£ÌøתʱµØÖ·À¸²»»á·¢Éú¸Ä±ä¡£Ö»ÄÜÔÚÕ¾µãÄÚÌøת¡£
Ìøת·½Ê½£¨3ÖÖ£©£º
Jsp¶¯×÷Ìøת£º<jsp:forword page="">
pageContext.forward("request2.jsp");
request.getRequestDispatcher("request2.jsp").forward(request,response);
¿Í»§¶ËÌøת£º
ÐèÒªÓû§²ÎÓëÌøת¹ý³Ì£¬µØÖ·À¸»á·¢Éú¸Ä±ä£¬¿ÉÒÔÏòÕ¾µãÍâ½øÐÐÌøת¡£
Ìøת·½Ê½£¨5ÖÖ£©£º
³¬¼¶Á´½Ó£º<a href="">
response.senRedirect("");
<meta http-equiv="refresh" content="3;url=2.jsp">//3ÃëÍù2.jspÒ³ÃæË¢ÐÂÒ»´Î£¡
javascript; history.back();
response.setHeader("refresh","3;url=request2.jsp");
ÔÚJSPÖУ¬ÌøתҳÃæÓÐÁ½ÖÖ·½Ê½£º
1.forwardÌøת£º<jsp:forward page="ÌøתҳÃæµØÖ·" />
2.responseÌøת£ºresponse.sendRedirect("ÌøתҳÃæµØÖ·");
Á½ÖÖÌø
Ïà¹ØÎĵµ£º
JAVA×ÛºÏÃæÊÔÌ⣺ҳÃæµÄץȡ¡¢½âÎö¡¢±£´æÊý¾Ý¿âºÍÉú³ÉHTMLµÄÒ³Ãæչʾ ÊÕ²Ø
´ÎÀý×Ó¿ÉÒÔÓÃÀ´Ñ§Ï°ÍøÂç±à³Ì£¬ÕýÔò±í´ïʽµÄʹÓ㬷ºÐÍ£¬Êý¾Ý¿âµÄ»ù±¾²Ù×÷µÈJAVA֪ʶ
ÎÊÌâÈçÏ£ºÀ´Ô´ÓÚÂÛ̳
http://topic.csdn.net/u/20090616/13/59aa4e2d-3752-45df-9c1b-c65c46c3e4d7.html
дһ¸öjspÒ³Ã棬·ÃÎÊʱÏÔʾ´ÓÏÂÃæµÄÒ³ÃæÌ ......
Ò»£¬´¿´âµÄjspÒ³ÃæÖÐÎÄÂÒÂë
ÔÒò£º¶Ôjsp´úÂëµÄ±àд£¬Ä¬ÈϵÄ×Ö·û¼¯Ê“ISO-8859-1”£¬Èç¹û´úÂëÖдæÔÚÖÐÎÄ£¬Ôò»á³öÏÖÂÒÂ룡
½â¾ö°ì·¨£ºÔÚpageÖмÓÉÏcontentType="text/html;charset=gb2312"£¬²ÉÓùú±êÀ´·ÒëÒ³ÃæÖеĴúÂ룡
¶þ£¬post·½Ê½Ìá½»±íµ¥³öÏÖÂÒÂë
ÔÒò£º ......
»·¾³£ºAjax+JSP£¬Tomcat5.05
²Î¿¼£ºhttp://www.w3cschool.cn/index-24.asp.htm
Îļþ£ºtestAjax.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb ......
Ç°ÑÔ
ÔÚʹÓÃÊý¾Ý¿âµÄ¹ý³ÌÖУ¬²»¿É±ÜÃâµÄÐèҪʹÓõ½·ÖÒ³µÄ¹¦ÄÜ£¬¿ÉÊÇJDBCµÄ¹æ·¶¶Ô´ËȴûÓкܺõĽâ¾ö¡£¶ÔÓÚÕâ¸öÐèÇóºÜ¶àÅóÓѶ¼ÓÐ×Ô¼ºµÄ½â¾ö·½°¸£¬±ÈÈçʹÓÃVectorµÈ¼¯ºÏÀàÏȱ£´æÈ¡³öµÄÊý¾ÝÔÙ·ÖÒ³¡£µ«ÕâÖÖ·½·¨µÄ¿ÉÓÃÐԺܲÓëJDBC±¾ÉíµÄ½Ó¿ÚÍêÈ«²»Í¬£¬¶Ô²»Í¬ÀàÐ͵Ä×ֶεÄÖ§³ÖÒ²²»ºÃ¡£ÕâÀïÌṩÁËÒ»ÖÖÓëJDBC¼æÈÝÐԷdz£ºÃµÄ·½°¸ ......
·ÖÁ½ÖÖ£º
Get·½Ê½´«µÝÊý¾Ý½â¾ö°ì·¨£º
<%
String username = request.getParameter("username");
byte[] bytes = username.getBytes("iso-8859-1");
String result = new String(bytes, "gb2312");
out.print(result);
%>
Post·½Ê½½â¾ö°ì·¨£ºrequest.setCharacterEncoding("gb2312");
......