代码块
代码块语法遵循标准markdown代码,例如:
$("#pageForm").ajaxSubmit({
type: "POST",
url:"你的action.html",
dataType: "json",
success: function(data){
if(data.msg=='SUCCESS'){
alert(success);
}
else{
alert(data.msg);
}
}
});
@RequestMapping("/insertGoodsBrand")
public void insertGoodsBrand(
HttpServletRequest request,
@RequestParam(value = "file", required = false) MultipartFile file,HttpServletResponse response,
GoodsBrand goodsBrand){
JSONObject obj = new JSONObject();
PrintWriter out = null;
try {
out = response.getWriter();
String path = request.getSession().getServletContext().getRealPath(
"upload\\goods\\brand");
String fileName = file.getOriginalFilename();
String saveFileName = Common.getNowCorrect2Second() + "."
+ fileName.substring(fileName.lastIndexOf(".") + 1);
File targetFile = new File(path, saveFileName);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String msg = "";
file.transferTo(targetFile);
msg = backGoodsBrandBus.insertGoodsBrand(goodsBrand, saveFileName);
if (msg.equals("SUCCESS")) {
obj.put("msg", msg);
} else {
obj.put("msg", msg);
}
out.print(obj);
} catch (Exception e) {
e.printStackTrace();
}
finally{
out.close();
}
}