¹ýÂËÆ÷ÖÐÏòËùÓÐJSPÒ³Ãæ²åÈëhtml´úÂë
Ϊ¹«Ë¾ÄÚ²¿¿ª·¢ÁË1¸ö¼òµ¥µÄMVC¿ò¼Ü£¬¿ò¼ÜÖÐÐèÒªÏòËùÓÐJSPÒ³ÃæµÄ<head>ÖвåÈë2ÌõÒýÓÃJSµÄ´úÂ룬ʵÏÖÈçÏ£º
Ö÷ÒªÊǼ̳ÐHttpServletResponseWrapperд1¸öÀà(PageResponseWrapper),´úÂ룺
1 public class PageResponseWrapper extends HttpServletResponseWrapper {
2 private Buffer buffer;
3 private HttpServletResponse originalResponse;
4
5 public PageResponseWrapper(final HttpServletResponse response){
6 super(response);
7 this.originalResponse = response;
8 buffer = new Buffer();
9 }
10
11 @Override
12 public PrintWriter getWriter() throws IOException {
13 return buffer.getWriter();
14 }
15
16 public CharArrayWriter getContent(){
17 return buffer.getBufferedWriter();
18 }
19
20 public void close() throws IOException {
21 buffer.getWriter().close();
22 }
23
24 public void finalize() throws Throwable {
25 super.finalize();
26 buffer.getWriter().close();
27 }
28
29 &nbs
Ïà¹ØÎĵµ£º
GBK±àÂë
GBK±àÂëÊÇÖйúÖÆ¶©µÄ¡¢µÈͬÓÚUCSµÄеÄÖÐÎıàÂëÀ©Õ¹¹ú¼Ò±ê×¼¡£GBK¹¤×÷С×éÓÚ1995Äê10Ô£¬Í¬Äê12ÔÂÍê³ÉGBK¹æ·¶¡£¸Ã±àÂë±ê×¼¼æÈÝGB2312£¬¹²ÊÕ¼ºº×Ö21003¸ö¡¢·ûºÅ883¸ö£¬²¢Ìṩ1894¸öÔì×ÖÂë룬¼ò¡¢·±Ìå×ÖÈÚÓÚÒ»¿â¡£
UTF-8±àÂë
UTF-8±àÂë¿ÉÒÔͨ¹ýÆÁ±ÎλºÍÒÆÎ»²Ù×÷¿ìËÙ¶Áд¡£×Ö·û´®±È½Ïʱstrcmp()ºÍwcscmp()µÄ·µ»Ø½ ......
Ö»Ðè´ÓÊý¾Ý¿â²é³öÀ´ºóÔÚÏÔʾµÄµØ·½ÓÃ<pre></pre>±êÇ©ÐÞÊΣ¬ÈçÏ£º
<!--
<div style="font-size:12px;color:green;text-align:left">
<pre>
<%=
&n ......
ÕÒÏÂÃæÐ´·¨¡£
×¢Ò⣬¼Óµ¥ÒýºÅ£¬µÚ2¸ö°Ù·ÖºÅ֮ǰûÓпոñ£¬¶øÔÚjspÖе÷ÓõĻ°Òª¿Õ¸ñ¡£
You may be get some help from the code below.
<%
String str="str";
%>
<script>
function accessVar(){
var varStr='<%=str%>';
alert(varStr);// here will diplay ......
JSPÖÐfilter¹ýÂËÆ÷ÑéÖ¤Óû§µÇ¼
ÏÖÔÚJSPʹÓÃÔ½À´Ô½¹ã·ºÁË£¬ÓÈÆäÊǺܶàÕþ¸®µÄÍøÕ¾¶¼²ÉÓÃÁËJSP¼¼Êõ£¬Æä¹¦ÄÜÇ¿´óÇÒ°²È«¡£
³õѧÕߺܶàÓÐÕâô¸öÎÊÌ⣬¾ÍÊÇ£¬ÍøÕ¾µÄÒ»¸öȨÏÞÉèÖ㬱ÈÈçµÇ¼Óû§¿ÉÒԲ鿴ÄÄÐ©Ò³Ãæ£¬¶øÓοÍÓÖÓÐȨÏÞ¿ÉÒÔ¿´ÄÄЩÄÚÈÝÄØ£¿
JSPÊÇÇ¿´óµÄ£¬µ«Æä´úÂ뻹ÊÇÏà¶Ô·±ËöµÄ£¬ÆäʵÓÃÒ»¸ö¹ýÂËÆ÷(filter)¾Í¿ÉÒÔʵÏÖÕ ......