jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á
¹Ø¼ü×Ö: jsp´«µÝÖÐÎIJÎÊý¡¢¿Õ¸ñÒÔ¼°±íµ¥ÄÚÈÝ»»ÐÐÎÊÌâ½â¾öС½á
ÔÚÀàËÆÁôÑÔ°åµÄwebÓ¦ÓÃÖУ¬ÐèÒª½«<textarea>ÖеĴó¶ÎÎÄ×ÖÏÔʾÔÚJspÒ³ÃæÉÏ£¬Òò´ËÐèÒª¶ÔÎÄ×ÖÖеÄÌØÊâ×Ö·ûÈç»»ÐС¢¿Õ¸ñµÄ×÷´¦Àí£¬·½·¨ÈçÏ£º
1¡¢Ö±½Ó±£´æ£¬È»ºóµ±´ÓÊý¾Ý¿âÖÐÈ¡³öÀ´Ê±ÓùýÂË·½·¨¹ýÂËÒ»±éÔÙËÍ»ØÒ³Ãæ¼´¿É£¬¸øÒ»¶Î´úÂ룬¿´Á˾ÍÃ÷°×ÁË£¬¿ÉÒÔ×Ô¼ºÀ©³ä
public static String filter(String value) {
if (value == null)
return (null);
StringBuffer result = new StringBuffer();
for (int i = 0; i < value.length(); i++) {
char ch = value.charAt(i);
if (ch == '<')
result.append("<");
else if (ch == '>')
result.append(">");
else if (ch == '&')
result.append("&");
else if (ch == '"')
result.append(""");
else if (ch == '\r')
result.append("<BR>");
else if (ch == '\n') {
if (i > 0 && value.charAt(i - 1) == '\r') {
} else {
result.append("<BR>");
}
} else if (ch == '\t')
result.append("  ");
else if (ch == ' ')
result.append(" ");
else
result.append(ch);
}
return (result.toString());
}
2¡¢ÔÚactionÖÐÓÃreplaceAll()°Ñ¿Õ¸ñ»Ø³µÌæ»»³öÀ´£¬
replaceAll(“\r\n“,“<br>“);
replaceAll(“ “,“\b“);
ÔÚjspÒ³ÃæÖУ¬Èç¹ûÓÃ<bean:write>Ôò¼ÓÉÏfilter="false"£¬
<bean:write name="info" property="content" filter="false"/>
3¡¢ÀûÓÃÑùʽ±í,ÔÚÏÔÊ¾Ò³ÃæÖзÅÖÃÒ»¸ö“͸Ã÷”µÄ<textarea>£¬¼´±ß¿òÑÕÉ«ºÍÎı¾¿òÑÕÉ«¶¼Óë±³¾°ÑÕɫһÖµÄÎı¾¿ò£¬È»ºó½«Òª
ÏÔʾµÄÄÚÈÝ·ÅÖõ½¸ÃÎı¾¿òÖУ¬ÕâÑù²»ÐèÒª×öÈκδ¦Àí£¬¶øÇÒ¾ø¶ÔºÍÓû§ÊäÈëµÄ¸ñʽһģһÑù£¬¸öÈËÈÏΪÊÇ×îºÃµÄ·½·¨¡£µ±È»£¬Ç§ÍòÒª¼Çס°ÑÕâ¸öÎı¾¿òÉèÖóÉÖ»¶Á
µÄ°¡£¬ºÙºÙ
textareaÀïµÄÄÚÈÝ×Ô¶¯»»ÐÐÊä³ö
soking ·¢±íÓÚ - 2005-8-31 9:59:00
Ö»ÒªÉèÖñí¸ñµÄcss¾ÍÐÐÁË¡£¼òµ¥ÊµÓã¡£¡
td {
word-break:break-all;
}
Ïà¹ØÎĵµ£º
×î½üÔÚдJSPµÄСÏîÄ¿£¬²»Ïë°ÑÊý¾Ý¿â£¬Êý¾ÝÎļþ¼Ð·¾¶µÈÅäÖÃÐÅϢдËÀÔÚ´úÂëÖУ¬ÓÚÊÇ×ÁÄ¥ÓÃxmlÅäÖÃÎļþµÄ·½·¨£¬ÏÖÔÚ½«Ê¹ÓÃÐĵÃ×ܽáһϣº
1.³ýÁËÒýÈëdom4j.jar°üÖ®Í⣬ʹÓÃXPATH±ØÐëÒýÈëjaxen.jar°ü£¬·ñÔòÀÏÊDZ¨´í¡£(ÔÚdom4jµÄ½âѹÎļþ¼ÐϵÄlibÎļþ¼ÐÖпÉÒÔÕÒµ½jaxen.jar)
2.ÖØµã£ºÓÉÓÚÊÇÒªÔÚtomcat»·¾³Ö®ÏÂʹÓÃjava·ÃÎÊÎÄ ......
ÕâÁ½¸öÐÇÆÚ³ýÁËרҵ¿Î·½ÃæµÄѧϰ£¬Ò»Ö±ÔÚѧϰJSP£¬ÓõÄÊÇ¡¶21ÌìѧͨJAVA WEB¿ª·¢¡·Õâ±¾»ù´¡ÈëÃŽ̲ģ¬Ê鱾ɿ¼°µ½µÄ¶«Î÷²¢²»¶à£¬Ñ§µÄ»¹ÊÇһЩ±È½ÏdzÏԵĶ«Î÷°É¡£Ò²ÐíºÜ¶à¶«Î÷ÕæµÄÒª½Ó´¥ÁËÖ®ºó²Å»áÓиоõ£¬×÷Ϊ¸Õ¸Õ½Ó´¥web¿ª·¢µÄ²ËÄñ¶øÑÔ£¬Äܹ»½«Ð´µÄ¶«Î÷ÔËÐÐÆðÀ´ÕæµÄºÜÓгɾ͸У¬(*^__^*) Îû ......
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔÊ¾Ò³Ãæ(display.jsp)¾Í³öÏÖÂÒÂ룺
<html>
<head>
<tit ......
tomcat6.0 + JSP + mysqlÊý¾Ý¿âÁ¬½Ó³ØÅäÖÃ
»·¾³£ºtomcat6.0 £¬mySQL 5.021
°ÑmysqlÇý¶¯°ü·Ö±ð·Åµ½%TOMCAT_HOME%/lib ºÍÄãµÄÓ¦ÓõÄWEB-INF\libÎļþ¼ÐÏÂÃæ
1¡¢ÐÞ¸Ä%TOMCAT_HOME%/conf/server.xml,Ìí¼ÓÈçÏÂÄÚÈÝ£¨²¿·Ö²ÎÊýÇë±¾µØ»¯£©£º
<Context path="/web" docBase="web" ......
ÏÖÔÚÓкöà³õѧjspµÄÍøÓѾ³£»áÎÊÊý¾Ý¿âÔõôÁ¬½Ó°¡£¬ÔõôÀϳö´í°¡£¿ËùÒÔÎÒ¼¯ÖеÄÔÚÕâдƪÎÄÕ¹©´ó¼Ò²Î¿¼£¬ÆäʵÕâÖÖ°ÑÊý¾Ý¿âÂ߼ȫ²¿·ÅÔÚjspÀïδ±ØÊǺõÄ×ö·¨£¬µ«ÊÇÓÐÀûÓÚ³õѧÕßѧϰ£¬ËùÒÔÎÒ¾ÍÕâÑù×öÁË£¬µ±´ó¼Òѧµ½Ò»¶¨³Ì¶ÈµÄʱºò£¬¿ÉÒÔ¿¼ÂÇÓÃMVCµÄģʽ¿ª·¢¡£ÔÚÁ·Ï°ÕâЩ´úÂëµÄʱºò£¬ÄãÒ»¶¨½«jdbcµÄÇý¶¯³ÌÐò·Åµ½·þÎñÆ÷µÄÀà·¾ ......