Skip to content

Instantly share code, notes, and snippets.

@jarod-chan
Created July 26, 2012 02:39
Show Gist options
  • Save jarod-chan/3179933 to your computer and use it in GitHub Desktop.
Save jarod-chan/3179933 to your computer and use it in GitHub Desktop.
LeaveController.java
/**
* 启动请假流程
* @param leave
*/
@RequestMapping(value = "start", method = RequestMethod.POST)
public String startWorkflow(Leave leave, RedirectAttributes redirectAttributes, HttpSession session) {
try {
User user = UserUtil.getUserFromSession(session);
leave.setUserId(user.getId());
Map<String, Object> variables = new HashMap<String, Object>();
ProcessInstance processInstance = workflowService.startWorkflow(leave, variables);
redirectAttributes.addFlashAttribute("message", "流程已启动,流程ID:" + processInstance.getId());
} catch (ActivitiException e) {
if (e.getMessage().indexOf("no processes deployed with key") != -1) {
logger.warn("没有部署流程!", e);
redirectAttributes.addFlashAttribute("error", "没有部署流程,请在[工作流]->[流程管理]页面点击<重新部署流程>");
} else {
logger.error("启动投保流程失败:", e);
redirectAttributes.addFlashAttribute("error", "系统内部错误!");
}
} catch (Exception e) {
logger.error("启动投保流程失败:", e);
redirectAttributes.addFlashAttribute("error", "系统内部错误!");
}
return "redirect:/oa/leave/apply";
}
@jarod-chan
Copy link
Author

RedirectAttributes 用作重定向属性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment