jspÂÒÂë½â¾ö´óÈ«(ת×ÔcsdnÒ»¸ßÊÖ)
jspÖÐÎÄÏÔʾÂÒÂë½â¾ö·½°¸2006-12-27 22:56
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
JSPµÄÖÐÎÄ´¦Àí
¶Ô²»Í¬µÄWEB·þÎñÆ÷ºÍ²»Í¬µÄJDK°æ±¾£¬´¦Àí½á¹û¾Í²»Ò»Ñù¡£ÔÒò£º·þÎñÆ÷ʹÓõıàÂ뷽ʽ²»Í¬ºÍä¯ÀÀÆ÷
¶Ô²»Í¬µÄ×Ö·ûÏÔʾ½á¹û²»Í¬¶øµ¼Öµġ£½â¾ö°ì·¨£ºÔÚJSPÒ³ÃæÖÐÖ¸¶¨±àÂ뷽ʽ(gb2312),¼´ÔÚÒ³ÃæµÄµÚÒ»
ÐмÓÉÏ£º£¬¾Í¿ÉÒÔÏû³ýÂÒÂëÁË¡£ÍêÕûÒ³ÃæÈçÏÂ
£º
JSPµÄÖÐÎÄ´¦Àí
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
ÏÂÃæÊÇÒ»¸öÌá½»Ò³Ãæ(submit.jsp)£¬´úÂëÈçÏ£º
JSPµÄÖÐÎÄ´¦Àí
ÏÂÃæÊÇ´¦ÀíÒ³Ãæ(process.jsp)´úÂ룺
JSPµÄÖÐÎÄ´¦Àí
Èç¹ûsubmit.jspÌá½»Ó¢ÎÄ×Ö·ûÄÜÕýÈ·ÏÔʾ£¬Èç¹ûÌá½»ÖÐÎÄʱ¾Í»á³öÏÖÂÒÂë¡£ÔÒò£ºä¯ÀÀÆ÷ĬÈÏʹÓÃUTF
-8±àÂ뷽ʽÀ´·¢ËÍÇëÇ󣬶øUTF- 8ºÍGB2312±àÂ뷽ʽ±íʾ×Ö·ûʱ²»Ò»Ñù£¬ÕâÑù¾Í³öÏÖÁ˲»ÄÜʶ±ð×Ö·û¡£
½â¾ö°ì·¨:ͨ¹ýrequest.seCharacterEncoding ("gb2312")¶ÔÇëÇó½øÐÐͳһ±àÂ룬¾ÍʵÏÖÁËÖÐÎĵÄÕý³£
ÏÔʾ¡£Ð޸ĺóµÄprocess.jsp´úÂëÈçÏ£º
JSPµÄÖÐÎÄ´¦Àí
Èý¡¢Êý¾Ý¿âÁ¬½Ó³öÏÖÂÒÂë
Ö»ÒªÉæ¼°ÖÐÎĵĵط½È«²¿ÊÇÂÒÂ룬½â¾ö°ì·¨£ºÔÚÊý¾Ý¿âµÄÊý¾Ý¿âURLÖмÓÉÏ
useUnicode=true&characterEncoding=GBK ¾ÍOKÁË¡£
ËÄ¡¢Êý¾Ý¿âµÄÏÔʾÂÒÂë
ÔÚmysql4.1.0ÖÐ,varcharÀàÐÍ£¬textÀàÐ;ͻá³öÏÖÖÐÎÄÂÒÂ룬¶ÔÓÚvarcharÀàÐÍ°ÑËüÉèΪbinaryÊôÐÔ¾Í
¿ÉÒÔ½â¾öÖÐÎÄÎÊÌ⣬¶ÔÓÚtextÀàÐ;ÍÒªÓÃÒ»¸ö±àÂëת»»ÀàÀ´´¦Àí£¬ÊµÏÖÈçÏ£º
public class Convert {
/** °ÑISO-8859-1Âëת»»³ÉGB2312
*/
public static String ISOtoGB(String iso){
String gb;
try{
if(iso.equals("") || iso == null){
return "";
}
else{
iso = iso.trim();
gb = new String(iso.getBytes("ISO-8859-1"),"GB2312");
return gb;
}
}
catch(Exception e){
System.err.print("±àÂëת»»´íÎó£º"+e.getMessage());
return "";
}
}
}
°ÑËü±àÒë³Éclass£¬¾Í¿ÉÒÔµ÷ÓÃConvertÀàµÄ¾²Ì¬·½·¨ISOtoGB()À´×ª»»±àÂë¡£
Èç¹ûÄ㻹ÓÐʲô²»¶®Ö®´¦£ºÎÒ¸ø´ó¼ÒÍƼöÒ»¸öºÃµÄJSP-JAVAÍøÕ¾£º
http://www.phy.hbnu.edu.cn/dsp/
×ܽ᣺
1. ÔÚjspÖÐÈç¹ûÖ¸¶¨ÁË£¬ÄÇôÔÚ¸ÄjspÖÐËùÓй¹Ôì
µÄString£¨²»ÊÇÒýÓã©£¬Èç¹û沒ÓÐÖ¸¶¨±àÂ룬ÄÇôÕâЩStringµÄ±àÂëÊÇ
Ïà¹ØÎĵµ£º
response.sendRedirect("display.jsp");
request.getRequestDispatcher("display.jsp").forward(request,response);
jspµÄÒ³ÃæÌøתÓÐÁ½ÖÖ·½·¨£ºRequestDispatcher.forward()·½·¨ºÍHttpServletResponse.sendRedirect()·½·¨¡£
¡¡¡¡ËüÃǵÄÇø±ðÊÇ£º
¡¡¡¡RequestDispatcher.forward()·½·¨½öÊÇÈÝÆ÷ÖпØÖÆȨµÄתÏò£¬ÔÚ¿Í»§¶Ëä ......
Ò»¡¢×ܵÄÀ´ËµÕâ¸ö½×¶ÎÖ÷ҪѧϰÁËÒ»ÏÂÕâЩ·½ÃæµÄ֪ʶ
£¨1£©¶ÔÒѾÕÆÎÕÁ˵ÄHTML½øÒ»²½ÊìϤºÍϸ»¯
£¨2£©ÒÔÇ°²»´óÊìϤµÄCSSÓиö¸ü½øÒ»²ãµÄÈÏʶµÄÕÆÎÕ
£¨3£©ÔÚVBscriptµÄ»ù´¡ÉÏÈ«ÃæѧϰÁËjavascript£¬½Å±¾ÓïÑÔ¿é¿ÉÒÔ˵»ù±¾µÄ¶¼Ó¦¸ÃÄÜ×öµÄ³öÀ´¡£
£¨4£©Ç°ÆÚÒ²¶ÔjavaÖеÄTCPÐÒéºÍUDPÐÒéϵͳµÄѧϰÁËÒ»±é£¬Ò²¾ÍÊÇSOCKET±à³ÌÒ»¿ ......
JSP»ù±¾Óï·¨
´ó²¿·ÖJSP±»Ò»¸öÒÔ“<%” ¿ªÍ·ºÍÒÔ“%>”½áβµÄµÄ±ê¼ÇÀ¨ÔÚÆäÖС£ÔÚ¸üеÄJSP 1.1¹æ·¶³ǫ̈ºó£¬¾ÍÓÐÁËÓëXML¼æÈݵİ汾¡£
JSPÖ¸ÁîºÍ½Å±¾ÔªËØ
Directives <%@ directive %>
Declarations <%! declaration %>
Expressions <%= expression %>
Code Fragment/ ......
²»ÖªµÀÊDz»ÊÇÇý¶¯¼ÓÔØÓÐÎÊÌ⣬ÔÚMyEclipseÖÐдÁ˼òµ¥µÄÊý¾Ý¿â²âÊÔ³ÌÐòÕÒ²»µ½Çý¶¯À࣬ϣÍû´óϺÄܸøÓè°ïÖú£¬Ð»ÁË¡£
ÑÏÖØ: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: org.aspectj.lang.Signature
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClas ......
1.Ìí¼Ó host ¿é
ÿһ¸öJSPÐéÄâÖ÷»úÓÐËü×Ô¼ºµÄ host ¿é¡£Ã¿Ò»¸öÖÁÉÙÒª¶¨ÒåidÀ´Ö¸¶¨ÐéÄâÖ÷»úµÄÃû×ÖºÍÒ»¸örootÓ¦ÓóÌÐò¡£Ò»¸ö <root-directory>ͨ³£ÓÃÀ´ÎªÖ÷»ú¶¨Ò»¸öĬÈϵÄwebÓ¦ÓóÌÐò¡£
ÅäÖÃÎļþƬ¶Î£º
<server>
<host id='gryffindor.caucho.com'>
<root-directory>/home/www/gryf ......