/** * 获取工程路径 * * @return */ public static String getProjectPath() { // 如果配置了工程路径,则直接返回,否则自动获取。 String projectPath = Global.getConfig("projectPath"); if (StringUtils.isNotBlank(projectPath)) { return projectPath; } try { File file = new DefaultResourceLoader().getResource("").getFile(); if (file != null) { while (true) { File f = new File(file.getPath() + File.separator + "src" + File.separator + "main"); if (f == null || f.exists()) { break; } if (file.getParentFile() != null) { file = file.getParentFile(); } else { break; } } projectPath = file.toString(); } } catch (IOException e) { e.printStackTrace(); } return projectPath; }
@RequiresPermissions("test:testData:edit") @RequestMapping(value = "delete") public String delete(TestData testData, RedirectAttributes redirectAttributes) { testDataService.delete(testData); addMessage(redirectAttributes, "删除单表成功"); return "redirect:" + Global.getAdminPath() + "/test/testData/?repage"; }
@RequiresPermissions("test:testData:edit") @RequestMapping(value = "save") public String save(TestData testData, Model model, RedirectAttributes redirectAttributes) { if (!beanValidator(model, testData)) { return form(testData, model); } testDataService.save(testData); addMessage(redirectAttributes, "保存单表成功"); return "redirect:" + Global.getAdminPath() + "/test/testData/?repage"; }
private void prepareGetResponse( final HttpServletRequest request, final HttpServletResponse response, final boolean post) throws ServletException { SystemAuthorizingRealm.Principal principal = UserUtils.getPrincipal(); if (principal == null) { return; } String command = request.getParameter("command"); String type = request.getParameter("type"); // 初始化时,如果startupPath文件夹不存在,则自动创建startupPath文件夹 if ("Init".equals(command)) { String startupPath = request.getParameter("startupPath"); // 当前文件夹可指定为模块名 if (startupPath != null) { String[] ss = startupPath.split(":"); if (ss.length == 2) { String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + principal + "/" + ss[0] + ss[1]; FileUtils.createDirectory(FileUtils.path(realPath)); } } } // 快捷上传,自动创建当前文件夹,并上传到该路径 else if ("QuickUpload".equals(command) && type != null) { String currentFolder = request.getParameter("currentFolder"); // 当前文件夹可指定为模块名 String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + principal + "/" + type + (currentFolder != null ? currentFolder : ""); FileUtils.createDirectory(FileUtils.path(realPath)); } // System.out.println("------------------------"); // for (Object key : request.getParameterMap().keySet()){ // System.out.println(key + ": " + request.getParameter(key.toString())); // } }