0.学习教程
http://www.cnblogs.com/jiekzou/p/9205117.html
https://github.com/crossoverJie/SSM
1.gradle没刷新导致的jar包不能解析:
点击View->Tool Window->Gradle->点击面板里第一个按钮Refresh All.重新运行即可.
2.打开gradle构建的项目,import找到build.gradle文件确定.
3.mybatis注解like(http://lavasoft.blog.51cto.com/62575/1386870/):
&#64;Select("select * from girl where name like \"%\"#{name}\"%\"") 菜单 vcs ->Enable Version Control Integration选择git close项目,重新添加到eclipse,然后project->clean 查找第一个(https://www.cnblogs.com/liguoyi/p/5899179.html) Optional if (tmpCompany.isPresent()) { WbCompany company&#61;tmpCompany.get(); } ThreadLocal var c&#61;&#39; var ias&#61;[]; for(var i&#61;0;i<${atts.size()};i&#43;&#43;){ console.log(ias); 第一种需要input的name和requestparam里的value设置一直 &#64;RequestMapping("/uploadFile") if (uploadFiles &#61;&#61; null || uploadFiles.length <&#61; 0) { for (MultipartFile file : uploadFiles) { } 第二种 input的 name随便取 &#64;RequestMapping("/uploadFile1") public void uploadFile1(MultipartHttpServletRequest request, HttpServletResponse response, HttpSession session)throws IllegalStateException, IOException { List } (仅限window平台)将ffmpeg.exe放在webroot下 调用: ToMp3(request.getSession().getServletContext().getRealPath("/"), savePath); https://blog.csdn.net/luqyu/article/details/43525795 /** (跨平台) http://www.sauronsoftware.it/projects/jave/download.php下载jave.jar导入 http://mfan.iteye.com/blog/2032454 public static void changeToMp3(String sourcePath, String targetPath) { From:http://www.cnblogs.com/xuejianxiyang/p/7298303.html
public List4.mybatis insert 返回id自增的值
insert into member (member_name,member_phone_no)values(#{memberName},#{memberPhoneNo})
5.idea使用git版本控制
6.git提示非空目录:先在目录内执行git init命令
7.eclipse: class path resource [applicationContext.xml] cannot be opened because it does not exist;
20.java lambda linq
wbCompanyGzList.forEach(s->{
f.set(f.get()&#43;s.getMoney());
});21.jsp和js数组互操作
alert(c);
alert(&#39;
var fp&#61;&#39;${atts[0].filePath}&#39;;
//alert(fp);
}22.多文件上传
public void uploadFile(&#64;RequestParam(value &#61; "uploadFiles") MultipartFile[] uploadFiles, HttpServletRequest request, HttpServletResponse response,
HttpSession session) {
JSONObject param &#61; new JSONObject();
param.put("token", false);
param.put("datas", null);
param.put("msg", "请选择文件.");
ServletUtil.write(response, param.toString());
return;
}
String filename &#61; file.getOriginalFilename();
String oriName &#61; file.getOriginalFilename();
String extName &#61; oriName.substring(oriName.lastIndexOf(".")).toUpperCase();
if (!extension.contains(extName)) {
param.put("token", false);
param.put("datas", null);
param.put("msg", "不支持的文件格式.仅支持:" &#43; extension);
ServletUtil.write(response, param.toString());
}
String savePath&#61;serverPath&#43;"\\photo\\"&#43;UUID.randomUUID()&#43;"--"&#43;filename;
file.transferTo(new File(savePath));//保存
}
CommonsMultipartFile multipartFile &#61; null;
Iterator
while (itr.hasNext()) {
String str &#61; itr.next();
multipartFile &#61; (CommonsMultipartFile) request.getFile(str);
String fileName &#61; multipartFile.getOriginalFilename(); // 原文件名
CommonsMultipartFile mpf &#61; (CommonsMultipartFile) request.getFile(str);
mpf.transferTo(new File("c:\\upload\\"&#43;fileName));
uploadFiles.add(mpf);
} 23.ffmpeg将amr转mp3
* 将上传的录音转为mp3格式
* &#64;param webroot 项目的根目录
* &#64;param sourcePath 文件的相对地址
*/
public static void ToMp3(String webroot, String sourcePath){
//File file &#61; new File(sourcePath);
String targetPath &#61; sourcePath&#43;".mp3";//转换后文件的存储地址&#xff0c;直接将原来的文件名后加mp3后缀名
Runtime run &#61; null;
try {
run &#61; Runtime.getRuntime();
long start&#61;System.currentTimeMillis();
Process p&#61;run.exec(webroot&#43;"/ffmpeg -i "&#43;sourcePath&#43;" -acodec libmp3lame "&#43; targetPath);//执行ffmpeg.exe,前面是ffmpeg.exe的地址&#xff0c;中间是需要转换的文件地址&#xff0c;后面是转换后的文件地址。-i是转换方式&#xff0c;意思是可编码解码&#xff0c;mp3编码方式采用的是libmp3lame
//释放进程
p.getOutputStream().close();
p.getInputStream().close();
p.getErrorStream().close();
p.waitFor();
long end&#61;System.currentTimeMillis();
System.out.println(sourcePath&#43;" convert success, costs:"&#43;(end-start)&#43;"ms");
//删除原来的文件
//if(file.exists()){
//file.delete();
//}
} catch (Exception e) {
e.printStackTrace();
}finally{
//run调用lame解码器最后释放内存
run.freeMemory();
}
}
File source &#61; new File(sourcePath);
File target &#61; new File(targetPath);
AudioAttributes audio &#61; new AudioAttributes();
Encoder encoder &#61; new Encoder();
audio.setCodec("libmp3lame");
EncodingAttributes attrs &#61; new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}