团队冲刺3
今天,我将前端页面进行了简单设计以及排版状况进行设计
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <body background=""> </body> <title>简历解析结果</title> <link rel="stylesheet" href="Css/style.css"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script > function showTab(tabHeadId,tabContentId) { //tab层 var tabDiv = document.getElementById("tabDiv"); //将tab层中所有的内容层设为不可见 //遍历tab层下的所有子节点 var taContents = tabDiv.childNodes; for(i=0; i<taContents.length; i++) { //将所有内容层都设为不可见 if(taContents[i].id!=null && taContents[i].id != 'tabsHead') { taContents[i].style.display = 'none'; } } //将要显示的层设为可见 document.getElementById(tabContentId).style.display = 'block'; //遍历tab头中所有的超链接 var tabHeads = document.getElementById('tabsHead').getElementsByTagName('a'); for(i=0; i<tabHeads.length; i++) { //将超链接的样式设为未选的tab头样式 tabHeads[i].className='tabs'; } //将当前超链接的样式设为已选tab头样式 document.getElementById(tabHeadId).className='curtab'; document.getElementById(tabHeadId).blur(); } </script> </head> <body> <div style="width:20px;height:10px"> <div style="position:absolute;right:50px;bottom:0px;width:70px;border:1px solid #aaa" > <div id="datetime"> <script> setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000); </script> </div> <a style="color:blue" href='zhiyuan.jsp?' onclick="del()">回到首页</a> </div> </div> <div id="tabtitle" > <h2 style="text-align: center;color: darkblue" class="a"><img src="imgs\1.png" width="50" height="50" >智能简历解析</h2> </div> <div id="tabDiv" > <div id="tabsHead" > <a id="tabs1" class="curtab" href="javascript:showTab('tabs1','tabContent1')" > 智能提取 </a> <a id="tabs2" class="tabs" href="javascript:showTab('tabs2','tabContent2')"> 智能评估 </a> <a id="tabs3" class="tabs" href="javascript:showTab('tabs3','tabContent3')"> 人岗匹配 </a> </div> <div id="tabContent1" > <table id="table1" > 姓名:${people.cont_education} </table> </div> <div id="tabContent2" style="display: none"> 预估工资:${people.salary} </div> <div id="tabContent3" style="display: none"> </div> </div> <div style="text-align: center; width: 100%; font-size: 12px; color: #333;">©版权所有:石铁大软工赵金荣,曾雨坤,崔建铭</div> </body> </html>
<form action="/uploadServlet" method="post" ENCTYPE="multipart/form-data" > <div id="div1"> <div > 上传人:<input type="text" name="name"> </div> </div> <div id="file_input"> <textarea id="textarea_input" rows="10"></textarea></br> 上传文件: <input type="file" id="filecss" placeholder="文件上传" name="myfile" ><br> <p class="text-red">(支持格式:pdf|doc|docx|txt|odt|RTF|HTML|JPG等30多种格式, 最大8M)</p>
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String realpath=""; request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); DiskFileItemFactory factory=new DiskFileItemFactory(); File f=new File("D:\\target"); if(!f.exists()){ f.mkdirs(); } factory.setRepository(f); ServletFileUpload fileUpload=new ServletFileUpload(factory); fileUpload.setHeaderEncoding("utf-8"); try { List<FileItem> fileItems= fileUpload.parseRequest(request); for(FileItem fileItem:fileItems){ if(fileItem.isFormField()){ String name= fileItem.getFieldName(); String value= fileItem.getString("utf-8"); System.out.println("上传者:"+value); }else { String filename=fileItem.getName(); String result= UUID.randomUUID().toString(); filename=result+filename; System.out.println("文件名:"+filename); String webpath="/upload/"; String path=request.getSession().getServletContext().getRealPath(webpath+filename); System.out.println(path); realpath=path; File file=new File(path); file.getParentFile().mkdirs(); file.createNewFile(); FileOutputStream out=new FileOutputStream(file); InputStream inputStream=fileItem.getInputStream(); byte[] buffer=new byte[1024]; int len=-1; while ((len=inputStream.read(buffer))!=-1){ out.write(buffer,0,len); } inputStream.close(); out.close(); fileItem.delete(); } } } catch (FileUploadException e) { throw new RuntimeException(e); } try { People people= Service.Analysis(realpath); request.setAttribute("people",people); request.getRequestDispatcher("/zjr.jsp").forward(request,response); System.out.println("WEB层:"+people); } catch (Exception e) { throw new RuntimeException(e); } } }
通过此方法,我们成功将前端文件路径获取传给后端,实现了在控制台显示简历分析,下一步问题,如何将后端数据传入前端