티스토리 뷰

javascript

$("input[name=attachFile]").fileupload({

url : '<c:url value="/myurl.do"/>',
datatype : 'json',
formData : {
k1 : "k1",
atchFileId : $("#atchFileId").val(),
fileType : fileType
},
done : function(e, data){
var def = data.result[0].body.innerHTML;
var dt = jQuery.parseJSON(def);
if(dt.message == 'success'){
alert('파일 업로드가 완료되었습니다.');
}else{
alert('파일 업로드가 실패하였습니다.\n관리자에게 문의해주세요.');
}
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');



java 

@RequestMapping(value = "/myurl.do")
public void abc(MultipartHttpServletRequest request, HttpServletResponse response) throws IOException{

~

Map rtn= new HashMap<String, String>();

response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-chche");
response.setHeader("Content-type", "text/html");
response.setHeader("charset", "UTF-8");

PrintWriter outWriter=null;
Gson gson = new Gson();
outWriter = response.getWriter();
outWriter.print(gson.toJson(rtn));
outWriter.flush();

}

'웹개발자 > js_jquery' 카테고리의 다른 글

tooltip 개행  (0) 2018.11.30
handsontable number validator, copy paste error fix  (0) 2018.07.11
form 동적생성  (0) 2017.05.30
string to json  (0) 2017.05.30
json, object 데이터 크기 확인  (0) 2017.05.30
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함