杂记
个人日常开发遇到的问题,记忆力不好没办法,记录以防再次遇到。
Spring&Springmvc
日常开发Spring&Springmvc遇到的问题。(脑子记不住没办法)
SpringMVC怎么获取前台传来的数组
- 前台页面 JS
var ids = new Array();
ids.push(1);
ids.push(2);
$.ajax({
url : "xxx/xxx"
type : "post",
data : {
"ids" : ids},
dataType : "josn",
success : function() {
...
}
});
- Spingmvc 后台 controller 接收
@RequestMapping(value = "xxx")
@ResponseBody
public XXX xxx(@RequestParam("ids[]") List<Integer> ids) {
...
}
二维码
输出到页面
页面
<img src="xxxx/getQRcode" .../>
后台
@RequestMapping(value = "getQRcode")
public void getQRcode(HttpServletResponse response, String code) {
response.setHeader("Content-Type", "image/jpeg");
byte[] img = null;
try {
if(StringUtils.isNotBlank(code)) {
// 生成二维码
img = qRCodeUtilService.createQrImage(code, PathConstants.QR_LOGO);
}
response.getOutputStream().write(img);
response.flushBuffer();
} catch (Exception e) {
logger.error("create QRcode fail -- params : code={}", code, e);
}
}
JS
日常开发常用js
Checkbox 全选&全不选&全选判断
<input type="checkbox" id="check_all">
<input type="checkbox" class="checkbox">
<input type="checkbox" class="checkbox">
<script&