1.一对多映射,最好在多的一段维护关系(避免冗余update语句的出现,例如class对应student,如果由class维护关系,则会多次update掉student),设置少的一段set中的inverse=true。
2.在jsp中输出对象的集合属性的字段,使用jstl标签
<c:forEach items="${asstudent.reAndpu}" var="r">
${ r.name}
</c:forEach>
3.点击下载出现另存为的对话框
-
private void downValid(HttpServletResponse response,NetDiskFile netDiskFile)throws Exception{ try{ if(netDiskFile!=null){ File f = new File(netDiskFile.getAttach()); //文件流的输入 BufferedInputStream br = new BufferedInputStream(new FileInputStream(f)); response.reset(); response.setCharacterEncoding("gb2312"); response.setContentType("application/x-msdownload"); response.setHeader("Content-Disposition", "attachment; filename="+this.toUtf8String(netDiskFile.getFilename())+"."+netDiskFile.getSuffix()); byte[] buf = new byte[1024]; int len = 0; //文件流的输出 OutputStream output = response.getOutputStream(); while ((len = br.read(buf)) > 0){ output.write(buf, 0, len); } br.close(); output.close(); }else{ PrintWriter out=response.getWriter(); out.println("<script language='javascript'>alert(\"you only can download the file, can't do the folder!\");history.back();</script>"); } }catch(FileNotFoundException e){ PrintWriter out=response.getWriter(); out.print("<script language='javascript'>alert('Sorry,the file could not be found');history.back();</script>"); }catch(Exception e){ PrintWriter out=response.getWriter(); out.print("<script language='javascript'>alert('while downloading,the error happens.');history.back();</script>"); } }