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

jspת¾²Ì¬Àý×Ó

1¸öServlet£ºSetCharacterEncodingFilter.java
 
package com.util;
import java.io.IOException;
import javax.servlet.*;
public class SetCharacterEncodingFilter  implements Filter{
 protected String encoding = null;
 protected FilterConfig filterConfig = null;
 protected boolean ignore = true;
 public void destroy()
 {
    this.encoding = null;
    this.filterConfig = null;
 }
 public void doFilter(ServletRequest request, ServletResponse response,
     FilterChain chain) throws IOException, ServletException
 {
    if (ignore || (request.getCharacterEncoding() == null))
    {
     String encoding = selectEncoding(request);
     if (encoding != null)
      request.setCharacterEncoding(encoding);
    }
    chain.doFilter(request, response);
 }
 public void init(FilterConfig filterConfig) throws ServletException
 {
    this.filterConfig = filterConfig;
    // »ñÈ¡³õʼ»¯²ÎÊý
    this.encoding = filterConfig.getInitParameter("encoding");
    String value = filterConfig.getInitParameter("ignore");
    if (value == null)
    {
     this.ignore = true;
    } else if (value.equalsIgnoreCase("true"))
    {
     this.ignore = true;
    } else if (value.equalsIgnoreCase("yes"))
    {
     this.ignore = true;
    } else
     this.ignore = false;
 }
 protected String selectEncoding(ServletRequest request)
 {
    return (this.encoding);
 }
}
Ò»¸ö¹ýÂËÆ÷ JspFilter.java£º
package com.util;
import java.io.IOException;
import jav


Ïà¹ØÎĵµ£º

jsp URI´«µÝ²ÎÊý£¬¶Ô·½½ÓÊÜÊÇÂÒÂë½â¾ö·½·¨

ÕâÖ÷ÒªÊÇtomcatµÄÎÊÌ⣬Ëü»áÔÚ´«Ë͵Äʱºò°Ñ×Ö·û¼¯ÖØÐ±àÒ룬µÈ´«¹ýÈ¥µÄjspÒ³Ãæ½ÓÊܵÄʱºò¾Í»á³öÏÖÂÒÂ룬
²»¹ÜÔÚÒ³ÃæÀïÈçºÎÉèÖÃ×Ö·û¼¯¶¼Ã»°ì·¨½â¾ö£¬Õâʱºò±ØÐë±ØÐëÔÚtomcat°²×°Ä¿Â¼Àï½øÐÐÉèÖã¬
C:\Program Files\apache-tomcat-6.0.14\confĿ¼Ï server.xmlÏ <Connector/>±êǩϠ¼ÓÒ»¾ä URIEncoding="GBK" ¾ÍºÃÁ ......

JSPÖÐÓë·¾¶Ïà¹ØµÄ³£Óõö·½·¨


http:/localhost/123/jsp/test.jsp:
<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logi ......

jspµ÷Óô洢¹ý³Ì

  ÔÚsql2000Öд´½¨´æ´¢¹ý³Ì£º
--ÇóÁ½ÊýÖ®ºÍ
create proc up_sum @a int ,@b int ,@result int output
as
select @result= @a+@b
µ÷Ó÷½·¨£º
...
CallableStatement cstmt=con.prepareCall("exec  up_sum ?,?,?");
cstmt.registerOutParameter(3,java.sql.Types.INTEGER);
    &nb ......

jsp Ö®Filter

(1) ÇëÇóÐÅÏ¢±àÂëת»¯µÄFilter
importjava.io.IOException;
importjava.util.Enumeration;
importjavax.servlet.Filter;
importjavax.servlet.FilterChain;
importjavax.servlet.FilterConfig;
importjavax.servlet.ServletException;
importjavax.servlet.ServletRequest;
importjavax.servlet.ServletResponse;
......

jspµÄ9¸öÄÚ½¨¶ÔÏó

ÔÚjspÖв»Óö¨Òå¿ÉÒÔÖ±½ÓÓõľÍÊÇjspµÄ9¸öÄÚ½¨¶ÔÏóÁË
1£¬Request 2,Response 3,session 4,out 5,page
6,application 7,pageContext 8,config
9,exception
1¡¢Request¶ÔÏó
¸Ã¶ÔÏó·â×°ÁËÓû§Ìá½»µÄÐÅÏ¢£¬Í¨¹ýµ÷ÓøöÔÏóÏàÓ¦µÄ·½·¨¿ÉÒÔ»ñÈ¡·â×°µÄÐÅÏ¢£¬¼´Ê¹ÓøöÔÏó¿ÉÒÔ
»ñÈ¡Óû§Ìá½»µÄÐÅÏ¢¡£
µ±Request¶ÔÏó»ñÈ¡¿Í» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ