Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SetCharacterEncodingFilter jsp×Ö·û¹ýÂËÆ÷

package com.demo.filter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import java.io.IOException;
public class SetCharacterEncodingFilter implements Filter {
  protected FilterConfig filterConfig;
  protected String encodingName;
  protected boolean enable;
  public SetCharacterEncodingFilter() {
    this.encodingName = "GBK";
    this.enable = false;
  }
  public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
  }
  public void doFilter(ServletRequest request,
                       ServletResponse response,
                       FilterChain chain)
                    throws IOException, ServletException {
    request.setCharacterEncoding("GBK");
    response.setCharacterEncoding("GBK");
    chain.doFilter(request, response);
  }
  public void destroy() {
  }
}
————————————————————————————————————————————
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.


Ïà¹ØÎĵµ£º

jspÖжÁÈ¡propertiesÎļþ

jspÖжÁÈ¡propertiesÎļþ£¬²¢°ÑÖµÉèµ½js±äÁ¿ÖУº
web_stderr.propertiesÎļþÄÚÈÝ£º
common.username.error.null = UserName can not be null.
common.username.error.invalid = UserName is invalid.
common.password.error.null = Password can not bu null.
common.password.error.invalid = Password is invalid.
......

jspÖе¼Èë³£ÓñêÇ©

<%@taglib prefix="s" uri="/WEB-INF/tld/struts-tags.tld"  %>
<%@taglib prefix="c" uri="/WEB-INF/tld/c.tld"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="dec ......

JSP±àÂëÒÔ¼°ÂÒÂë½â¾ö×ܽá

Ò»Ö±ÒÔÀ´¶ÔJSPÖгöÏÖÂÒÂëµÄÎÊÌâ¶¼ºÜ»ìÂÒ£¬ÏÖ¾­¹ý²éÔÄ×ÊÁÏ£¬¶ÔJSPÂÒÂëÕâ¸öÎÊÌâÓбȽÏÉî¿ÌµÄÈÏʶ£¬Ï±ßÊÇÎÒµÄһЩ¸öÈË×ܽᣬϣÍû¸øÍ¬ÑùÃÔ»óµÄÈË´øÀ´°ïÖú¡£ ͬʱÈç¹û²»¶Ô£¬Ï£ÍûµÃµ½ÌáÐÑ£¬¹²Í¬½ø²½¡£
Ê×ÏÈ£¬ËµËµJSP/ServletÖеö±àÂëµÄ×÷Óãº
1.<%@page pageEncoding="UTF-8" %>
 ×÷Óãº
 * ¸æËßJSP±àÒë ......

JSP´¦Àí±íµ¥¼¼ÇÉ

1£º³¬Á¬½ÓÌø×ª
ÎÒÃÇÔÚ³¬Á¬½ÓµÄʱºò£¬³£³£Á¬½Óµ½Ò»¸öjsp»òÕßAction,±ÈÈç:
XXX
ÕâÑù×ö»áÓÐÒ»¸öÎÊÌ⣺ÔÚtest.jspÖУ¬³ýÄã´«µÝµÄparam1ºÍparam2²ÎÊýÍâ,ÄãÓÃrequest.getParamter()È¡ÈκÎÔ­À´Ò³ÃæµÄ±íµ¥ÔªËض¼»áΪ¿Õ£¬ÕâÊÇÒòΪÕâÖÖ·½Ê½»á²úÉúеÄrequestÉúÃüÖÜÆÚ£¬ÔÚÕâ¸örequestÖÐÖ»»á°üº¬³¬Á¬½Óºó¸úËæµÄ?param1ÕâÖÖ²ÎÊý£¬ Òò´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ