JQuery ajaxのpostメソッドactionへのファイルパスの文字化けし(非中国語文字化けし)
1189 ワード
Jquery post , :
js :
function loadChild(val){
//alert();
$.post('backstage/resource/toloadChild', {
path : "D:\tomcat-7.0.27\webapps\dssx\front\data\exam"
}, function(data) {
alert(data);
}, "xml");
}
アクションの コード:public String loadChild() throws UnsupportedEncodingException{
request = ServletActionContext.getRequest();
request.setCharacterEncoding("utf-8");//
File file = new File(request.getParameter("path"));
System.out.println(file.getPath());
return SUCCESS;
}
けしは のとおりです.
D: omcat-7.0.27webappsdssx rontdataexam
jsでescape("D:tomcat-7.0.27webappsdssxfrontdataexam")を うと、こうなります.
D%3A%09omcat-7.0.27webappsdssx%0Crontdataexam
WebページはUTF-8コードを しています
: は の の スラッシュを スラッシュに えるだけでいいことに づいた.