jspÂÒÂëÎÊÌâ½â¾ö·½°¸
1,Ò³ÃæÉϱàÂëÉèÖÃΪ"UTF-8"
2,дһ¸ö×Ö·û±àÂë¹ýÂËÆ÷, ÔÚweb.xmlÖÐÅäÖüÓÔعýÂËÆ÷
3,ÉèÖÃtomcatµÄÊôÐÔ ÔÚÅäÖö˿ڵĽڵãÉϼÓÈëÈçÏ´úÂë:URIEncoding="UTF-8"
1,´úÂëÈçÏÂ:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2,ʵÏÖ´úÂë:
package com.mww.comm;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class checkEcodingFelter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletrequest;
HttpServletResponse response = (HttpServletResponse) servletresponse;
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
filterChain.doFilter(servletrequest, servletresponse);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
ÔÚweb.xmlÖÐÅäÖùýÂËÆ÷:
<!-- ×Ö·û±àÂë¹ýÂË -->
<filter>
<filter-name>checkEcodingFelter </filter-name>
<filter-class>com.mww.comm.checkEcodingFelter </filter-class> <!-- ÅäÖùýÂËÆ÷Àà °üÃû+ÀàÃû -->
</filter>
<filter-mapping>
<filter-name>checkEcodingFelter </filter-name>
<url-pattern>/* </url-pattern> <!-- ¹ýÂËËùÓÐÒ³Ãæ-->
</filter-mapping>
3,ÔÚtomcatÅäÖö˿ڵĽڵãÉÏÅäÖøÃÊôÐÔURIEncoding="UTF-8" :
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEn
Ïà¹ØÎĵµ£º
Jsp ELÓï·¨
Àý£º
${sessionScope.user.sex}
ËùÓÐEL¶¼ÊÇÒÔ ${ ΪÆðʼ¡¢ÒÔ} Ϊ½áβµÄ¡£
ÉÏÊöEL·¶ÀýµÄÒâ˼ÊÇ£º´ÓSessionÈ¡µÃÓû§µÄÐÔ±ð¡£Èç¹ûʹÓÃ֮ǰJSP´úÂëµÄд·¨ÈçÏ£º
<%
User user = (User)session.getAttribute(”user”);
String sex = user.getSex( );
%>
Á½ÕßÏà±È½Ï֮ϣ¬¿ÉÒÔ·¢ÏÖELµÄÓï·¨± ......
1. ÈçºÎÈÃÑ¡ÖеÄÒ»ÐмǼ¸ßÁÁÏÔʾ£¿
http://topic.csdn.net/t/20050105/09/3699823.html
2. ÈçºÎÔÚÏÂÀÁбí¿òÀïÑ¡ÔñÒ»¸öÖµºóÌø³öд°¿Ú?
http://topic.csdn.net/t/20050107/15/3707444.html
3. ÈçºÎÔÚJSPÖÐÆô¶¯execl?
http://community.csdn.net/Expert/TopicView1.asp?id=4909154
http://community.csdn.net/Expert/ ......
ÎÒÃǶ¼ÖªµÀÔÚjspÖÐincludeÓÐÁ½ÖÖÐÎʽ,·Ö±ðÊÇ
< %@ include file=” ”%>
< jsp:include page=” ” flush=”true”/>
¡¡¡¡Ç°ÕßÊÇÖ¸ÁîÔªËØ¡¢ºóÕßÊÇÐÐΪԪËØ¡£¾ßÌåËüÃǽ«Ôںδ¦Óã¿ÈçºÎÓü°ËüÃÇÓÐʲôÇø±ð£¿ÕâÓ¦¸ÃÊǺܶàÈË¿´µ½Ëü¶¼»áÏëµ½µÄÎÊÌâ¡£ÏÂÃæÒ»ÆðÀ´¿´¿´°É¡£
¡ ......
±¾µØÓõÄÊÇtomcat6£¬ÔËÐÐÒ»Çж¼Õý³£¡£°Ñϵͳ²¿µ½Ô¶³ÌÉÏʱºò±¨Õâ¸ö´íÎó£º Syntax error on token "<", invalid AssignmentOperator
Syntax error on token "<", invalid AssignmentOperator
ÔÚÍøÉÏÕÒµ½ÔÒò£º
Õâ¸ö´íÎó¿ÉÄÜÊÇÒòΪÄãÔÚjspÖÐÓõ½ÁË·ºÐÍ¡£
°Ñ·ºÐÍÈ¥µôÊÔÊÔ¾Í ......