日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

javascript通過(guò)url向jsp頁(yè)面?zhèn)鬟f中文參數(shù)導(dǎo)致亂碼解決方案_JSP教程

編輯Tag賺U幣

推薦:jsp中實(shí)現(xiàn)上傳圖片即時(shí)顯示效果功能
上傳圖片時(shí)即時(shí)顯示圖片效果,這在項(xiàng)目開發(fā)中時(shí)很常見的一項(xiàng)功能,接下來(lái)介紹此功能的實(shí)現(xiàn)過(guò)程,有需要的朋友可以參考下

2013-1-16 10:35:49 org.apache.tomcat.util.http.Parameters processParameters
警告: Parameters: Character decoding failed. Parameter 'id' with value '%u8BA2%u5355' has been ignored. Note that the name and value quoted here may corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
Enter Servlet Get Method..
OK:
2013-1-16 10:35:49 org.apache.catalina.core.StandardWrapperValve invoke
嚴(yán)重: Servlet.service() for servlet suggest threw exception
java.lang.NullPointerException
at com.ont.demo.suggest.doGet(suggest.java:25)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

解決方法:在傳遞參數(shù)前將中文參數(shù)進(jìn)行兩次編碼,jsp頁(yè)面獲取參數(shù)后對(duì)中文參數(shù)進(jìn)行一次解碼,中文參數(shù)就不會(huì)變?yōu)閬y碼了!

參考例子
復(fù)制代碼 代碼如下:www.hl5o.cn

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.net.*" %>
<%
String str0="";
String str1="";
if(request.getParameter("param0")!=null){
str0=request.getParameter("param0");//直接獲取中文參數(shù)
}
try{
if(request.getParameter("param1")!=null){
str1=URLDecoder.decode(request.getParameter("param1"),"utf-8");//對(duì)中文參數(shù)進(jìn)行解碼
}
}catch(Exception e){
e.printStackTrace();
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var str="你好";
function test0(){
window.location="Test.jsp?param0="+str;//直接傳遞中文參數(shù)
}
function test1(){
window.location="Test.jsp?param1="+encodeURI(encodeURI(str));//對(duì)中文參數(shù)進(jìn)行雙層編碼后再傳遞
}
</script>
</head>
<body>
<input value=<%=str0 %>>
<input type="button" value="亂碼" onclick="test0()"><br>
<input value=<%=str1 %>>
<input type="button" value="正常" onclick="test1()">
</body>
</html>

分享:JSP頁(yè)面緩存cache技術(shù)--瀏覽器緩存介紹及實(shí)現(xiàn)方法
緩存的思想可以應(yīng)用在軟件分層的各個(gè)層面。它是一種內(nèi)部機(jī)制,對(duì)外界而言,是不可感知的;另外Browser也有緩存(如IE)這個(gè)大家也都知道(實(shí)現(xiàn)在 web server 上的緩存機(jī)制)越上層的緩存效果越好,越底層的緩存影響越深遠(yuǎn)

來(lái)源:模板無(wú)憂//所屬分類:JSP教程/更新時(shí)間:2013-04-22
相關(guān)JSP教程