jspÂÒÂëÎÊÌâ URL´«ÖµÂÒÂëÎÊÌâ
jspÂÒÂëÎÊÌâ½â¾ö
1¡¢Ò»°ãµÄjspÒ³ÃæÏÔʾÂÒÂë
<%@ page contentType="text/html; charset=UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èç¹ûjspÌá½»Ó¢ÎÄ×Ö·ûÄÜÕýÈ·ÏÔʾ£¬¶øÌá½»ÖÐÎÄʱ¾Í»á³öÏÖÂÒÂë¡£
ÔÒò£ºä¯ÀÀÆ÷ĬÈÏʹÓÃUTF-8±àÂ뷽ʽÀ´·¢ËÍÇëÇ󣬶øUTF- 8ºÍGB2312±àÂ뷽ʽ±íʾ×Ö·ûʱ²»Ò»Ñù£¬
ÕâÑù¾Í³öÏÖÁ˲»ÄÜʶ±ð×Ö·û
½â¾ö£ºÔÙjspÒ³ÃæÉ趨 <%request.seCharacterEncoding("UTF-8");%>¶ÔÇëÇó½øÐÐͳһ±àÂë
ΪÁ˱ÜÃâÿҳ¶¼ÒªÐ´request.setCharacterEncoding("UTF-8")£¬½¨ÒéʹÓùýÂËÆ÷¶ÔËùÓÐjsp
½øÐбàÂë´¦Àí£¬
¹ýÂËÆ÷——.javaÎļþ£º
public class SetCharacterEncodingFilter implements Filter{
/*¹ýÂËÆ÷,½â¾öÖÐÎÄÂÒÂëÎÊÌâ*/
protected String encoding = "UTF-8";
protected FilterConfig filterConfig = null;
protected boolean ignore = true;
public void destroy() {
// TODO Auto-generated method stub
this.encoding = null;
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
try {
// Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCh
Ïà¹ØÎĵµ£º
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Óʱ³öÏÖÂÒÂë
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾ ......
1£¬JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð£¿
¶¯Ì¬INCLUDEÓÃjsp:include¶¯×÷ʵÏÖ <jsp:include page="included.jsp" flush="true" />Ëü×ÜÊÇ»á¼ì²éËùº¬ÎļþÖеı仯£¬ÊʺÏÓÃÓÚ°üº¬¶¯Ì¬Ò³Ã棬²¢ÇÒ¿ÉÒÔ´ø²ÎÊý¡£
####Õâ¸öÊÇ°ÑÒýÓõÄjsp±àÒë³ÉservletÒÔºó£¬Ö±½Óµ÷ÓÃservletÀàµÄ×ö·¨¡£####
¾²Ì¬INCLUDEÓÃinc ......
Ò» ¡£×Ô¶¨ÒåJSP±êÇ©µÄ´¦Àí¹ý³Ì£º
¡¡ 1£®ÔÚJSPÖÐÒýÈë±êÇ©¿â£º
¡¡ 2£®ÔÚJSPÖÐʹÓñêÇ©¿â±êÇ©
¡¡ 3£®WebÈÝÆ÷¸ù¾ÝµÚ¶þ¸ö²½ÖèÖеÄprefix£¬»ñµÃµÚÒ»¸ö²½ÖèÖÐÉùÃ÷µÄtaglibµÄuriÊôÐÔÖµ
¡¡ 4£®WebÈÝÆ÷¸ù¾ÝuriÊôÐÔÔÚweb.xmlÕÒµ½¶ÔÓ¦µÄÔªËØ
5£®´ÓÔªËØÖлñµÃ¶ÔÓ¦µÄÔªËصÄÖµ
6£®WebÈÝ ......
ÔÚ±àдJSP³ÌÐòʱ£¬³£³£»áÅöµ½ÖÐÎÄ×Ö·û´¦ÀíµÄÎÊÌ⣬ÔÚ½ÓÊÜrequestµÄÖÐÎÄ×Ö·ûʱÏÔʾ³öÀ´Ò»´®ÂÒÂë¡£ÍøÉÏ´¦Àí·½·¨Ò»Âá¿ð£¬ÏÂÃæ˵˵ÎÒÓùýµÄÁ½ÖÖÓÐЧµØ½â¾ö°ì·¨£º
1.Ϊ³ÌÐò±àдһ¸ö×Ö·û´®´¦Àíº¯Êý£¬ÓÃÒ»¸ö¾²Ì¬Îļþ±£´æ£¬ÔÚÐèÒª´¦ÀíÖÐÎÄ×Ö·ûµÄJSPÒ³ÃæÖаüº¬Ëü£¬
<%!
public String codeToString(String str)
{ ......
½â¾öjsp»òserverlet ²»ÄܽâÎömultipart/form-data ÀàÐÍµÄ±íµ¥ÓòµÄÎÊÌâ
10 6ÔÂ 2008
Situation:
Javax.servlet.HttpServletRequest.getParameter(String) returns null when the ContentType is multipart/form-data
Solutions:
Solution A:
1. download http://www.servlets.com/cos/index.html
2. invoke getPara ......