org.apache.struts2.convention.annotation.Action Java Examples
The following examples show how to use
org.apache.struts2.convention.annotation.Action.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrderAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
@Action(value = "toFifth", results = { @Result(name = "stepFifthUI", location = ViewLocation.View_ROOT + "orderstep4.jsp") }) public String toFifth() throws Exception{ //未支付押金订单生成 Mrcodeorder order = null; if((order=createOrder())!=null){ for(Password p : order.getPasswords()){ String msg = "【码团网】"+p.getContactors().getName()+"您好!您已下单成功,日期:"+p.getEstimatedTime().toString().substring(0,10)+ ",房间:"+p.getRoom().getRoomNumber()+"。酒店正为您办理入住手续,至酒店确认本人身份后,凭房间密码"+p.getPassword()+"即可入住。"; System.out.println("message:"+msg); JSONObject o = JSONObject.fromObject(MessageSend.sendSms(msg, p.getContactors().getPhoneNumber())); System.out.println("result:"+o); } request.setAttribute("msg", "已完成房间入住手续,请至酒店前台核对身份证,并支付押金,即可入住,谢谢!"); } return "stepFifthUI"; }
Example #2
Source File: SysMenuPermissionAction.java From EasyEE with MIT License | 6 votes |
@Action("save") public String save() throws Exception { msg = getText("msg.saveSuccess"); try { //设置排序位置为最大 sysMenuPermission.setSortNum(sysMenuPermissionService.getMaxSortNum(sysMenuPermission.getSysMenuPermission().getMenuPermissionId())+1); //添加根节点 if(sysMenuPermission.getSysMenuPermission().getMenuPermissionId()==-1){ sysMenuPermission.setSysMenuPermission(null); } sysMenuPermissionService.add(sysMenuPermission); } catch (Exception e) { e.printStackTrace(); logger.error(getText("sys.MenuPermissionAction.saveException"), e); msg = getText("msg.saveFail"); statusCode=StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #3
Source File: OrderAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
@Action(value = "toThird", results = { @Result(name = "stepThirdUI", location = ViewLocation.View_ROOT + "orderstep2.jsp") }) public String toThird() throws Exception{ //TODO 跳转至第三步,订单展示及确认页面 Customer customer = (Customer)session.get(Const.CUSTOMER); String ids = getParameter("ids"); List<Room> rooms = roomService.getByIds(ids); List<Contactors> contactors = contactorsService.getContactorsByCustomerId(customer); Integer days = (Integer)session.get("days"); Roomtype roomtype = (Roomtype)session.get("roomtype"); //需要使用的团购券,放入session Integer needVouchers = days*rooms.size(); pageBean.setPageSize(needVouchers); List<Grouppurchasevoucher> vouchers = grouppurchasevoucherService.getByType(customer, roomtype, pageBean); session.put("vouchers", vouchers); request.setAttribute("total", needVouchers*vouchers.get(0).getPrice()); session.put("rooms", rooms); request.setAttribute("contactors", contactors); return "stepThirdUI"; }
Example #4
Source File: SysMenuPermissionAction.java From EasyEE with MIT License | 6 votes |
/** * 更新 * @return * @throws Exception */ @Action("move") public String move() throws Exception { msg = getText("msg.moveSuccess"); try { sysMenuPermissionService.move(sysMenuPermission.getMenuPermissionId(), up); reloadPermissions(); //自动刷新菜单权限 } catch (Exception e) { e.printStackTrace(); logger.error(getText("sys.MenuPermissionAction.moveException"), e); msg = getText("msg.moveFail"); statusCode=StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #5
Source File: SysMenuPermissionAction.java From EasyEE with MIT License | 6 votes |
/** * 删除 * @return * @throws Exception */ @Action("delete") public String delete() throws Exception { msg = getText("msg.deleteSuccess"); try { sysMenuPermission=sysMenuPermissionService.get(sysMenuPermission.getMenuPermissionId()); if(sysMenuPermissionService.hashChildMenu(sysMenuPermission.getMenuPermissionId())){ msg = getText("sys.MenuPermissionAction.deleteMsg"); statusCode=StatusCode.ERROR; }else{ sysMenuPermissionService.delete(sysMenuPermission); reloadPermissions(); //自动刷新菜单权限 } } catch (Exception e) { e.printStackTrace(); logger.error(getText("sys.MenuPermissionAction.deleteException"), e); msg = getText("sys.MenuPermissionAction.deleteException"); statusCode=StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #6
Source File: IndexAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
@Action(value="toOrder", results={@Result(name="orderUI", location=ViewLocation.View_ROOT+ "hotel.jsp")}) public String toOrder() throws Exception{ //TODO 跳转到选择团购券的页面 Customer customer = (Customer)session.get(Const.CUSTOMER); List<Grouppurchasevoucher> gps = grouppurchasevoucherService.getByCust(customer); //把数据封装成Map Map<Roomtype, List<Grouppurchasevoucher>> rgMap = new LinkedHashMap<Roomtype, List<Grouppurchasevoucher>>(); for(Grouppurchasevoucher gp : gps){ if(!rgMap.containsKey(gp.getRoomtype())){ List<Grouppurchasevoucher> grps = new LinkedList<Grouppurchasevoucher>(); rgMap.put(gp.getRoomtype(), grps); } rgMap.get(gp.getRoomtype()).add(gp); } request.setAttribute("rgMap", rgMap); return "orderUI"; }
Example #7
Source File: OrderAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
@Action(value = "addContactor") public void addContactor(){ //TODO 添加联系人,成功返回 1,失败返回0 try { Customer customer = (Customer)session.get(Const.CUSTOMER); String userName = getParameter("name"); String phoneNumber = getParameter("phone"); String identityCard = getParameter("idCard"); if (contactorsService.isExist(identityCard, customer)) { writeStringToResponse("0"); return ; } Contactors cont = new Contactors(); cont.setCustomer(customer); cont.setIdentityCard(identityCard); cont.setName(userName); cont.setPhoneNumber(phoneNumber); cont.setIsSelf(0); Integer id = contactorsService.save(cont); writeStringToResponse(id.toString()); } catch (Exception e) { // TODO: handle exception writeStringToResponse("0"); } }
Example #8
Source File: LoginPhoneAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
/** * 发送短信验证码 * * @return */ @Action(value = "sendVerification") public void sendVerification() throws Exception { String phone = getParameter("phone"); System.out.println("CustomerAction.sendVerification()"); // 1.生成验证码 String verificationCode = MessageSend.getVerificationCode(); try { JSONObject result = JSONObject .fromObject(MessageSend.sendDynamicVerification( verificationCode, phone)); if ("OK".equals(result.get("msg"))) { session.clear(); session.put("verificationCode", verificationCode); writeStringToResponse("【ok】"); } } catch (Exception e) { log.error("发送验证码失败!"); e.printStackTrace(); } }
Example #9
Source File: SysLogAction.java From EasyEE with MIT License | 6 votes |
@SuppressWarnings("rawtypes") @Action("list") public String list() throws Exception { if (!isNotNullAndEmpty(sort)) { sort="logTime"; } if (!isNotNullAndEmpty(order)) { order="desc"; } PageBean pb = super.getPageBean(); // 获得分页对象 pb.setSort(sort); pb.setSortOrder(order); sysLogService.findByPage(pb, sysLogCriteria); super.setJsonPaginationMap(pb); return JSON; }
Example #10
Source File: SysOperationPermissionAction.java From EasyEE with MIT License | 6 votes |
@Action("save") public String save(){ try { sysOperationPermissionService.add(sysOperationPermission); msg=getText("msg.saveSuccess"); super.reloadPermissions(); //刷新权限 } catch (Exception e) { logger.error(getText("sys.OperationPermissionAction.saveException"),e); e.printStackTrace(); msg=getText("msg.saveFail"); statusCode=StatusCode.ERROR; } Map<Object,Object> rowData = new HashMap<Object,Object>(); rowData.put("operationPermissionId", sysOperationPermission.getOperationPermissionId()); setJsonMsgMap("rowData", rowData); return JSON; }
Example #11
Source File: DeptAction.java From EasyEE with MIT License | 6 votes |
@Action("delete") public String delete(){ try { if(empService.findEmpCountByDeptno(dept.getDeptno())==0){ deptService.delete(dept.getDeptno()); }else{ super.msg=getText("hr.DeptAction.empExists"); statusCode=StatusCode.ERROR; } } catch (Exception e) { e.printStackTrace(); statusCode=StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #12
Source File: EmpAction.java From EasyEE with MIT License | 6 votes |
/** * 分页 * * @return */ @SuppressWarnings("rawtypes") @Action("list") public String list() { PageBean pb = super.getPageBean(); // 获得分页对 empService.findByPage(pb, empCriteria); // EasyUI框架响应结果都是JSON // JSON数据初始化,包含EasySSH Ajax响应信息和分页信息 // 使用抽取的集合作为分页数据 // List<Map> list = EasyObjectExtract.extract(pb.getData(), // "empno","ename", // "job", "dept.dname#dname"); // // 使用抽取的集合作为分页数据 // pb.setData(list); super.setJsonPaginationMap(pb, "allDept", deptService.findAll()); return JSON; }
Example #13
Source File: LoginAction.java From java-course-ee with MIT License | 6 votes |
@Override @Action(value = "login-action", results = { @Result(name = "input", location = "login.jsp"), @Result(name = "success", location = "success.jsp"), @Result(name = "failure", location = "failure.jsp") }) @Validations(requiredStrings = { @RequiredStringValidator(fieldName = "loginBean.username", type = ValidatorType.FIELD, key = "username_required"), @RequiredStringValidator(fieldName = "loginBean.password", type = ValidatorType.FIELD, key = "password_required") }) public String execute() throws Exception { if ("gemini".equals(loginBean.getUsername()) && "systems".equals(loginBean.getPassword())) { return "success"; } else { return "failure"; } }
Example #14
Source File: EmpAction.java From EasyEE with MIT License | 6 votes |
@Action("delete") public String delete() { // try { // empService.delete(emp.getEmpno()); // } catch (Exception e) { // e.printStackTrace(); // statusCode=StatusCode.ERROR; // } // super.setJsonMsgMap(); // 批量删除 try { empService.delete(empno); // sysUserService.delete(sysUser.getUserId()); } catch (Exception e) { e.printStackTrace(); // 出错输出 500 响应 // ServletActionContext.getResponse().setStatus(500); statusCode = StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #15
Source File: SocialAuthUploadPhotoAction.java From socialauth with MIT License | 6 votes |
/** * Update status for the given provider. * * @return String where the action should flow * @throws Exception * if an error occurs */ @Action(value = "/socialAuthUploadPhotoAction") public String execute() throws Exception { SASFHelper helper = SASFStaticHelper.getHelper(request); SocialAuthManager manager = helper.getAuthManager(); AuthProvider provider = null; if (manager != null) { provider = manager.getCurrentAuthProvider(); } if (provider != null) { try { provider.uploadImage(statusMessage, imageFileFileName, new FileInputStream(imageFile)); request.setAttribute("Message", "Status Updated successfully"); return "success"; } catch (SocialAuthException e) { request.setAttribute("Message", e.getMessage()); e.printStackTrace(); } } return "failure"; }
Example #16
Source File: RoomManageAction.java From xmu-2016-MrCode with GNU General Public License v2.0 | 6 votes |
@Action(value = "toRoomManageFail") public void toRoomManageFail() throws Exception{ if(ActionContext.getContext().get("msg")!=null) request.setAttribute("msg", ActionContext.getContext().get("msg")); Customer cus = (Customer) session.get("customer"); String phoneNumber = cus.getPhoneNumber(); System.out.println("phoneNumber--" + phoneNumber ); //1、先根据该用户电话号码得到,password对象 Password passwd = passwordService.getPasswordByPhone (phoneNumber); if(passwd == null) { // 代表无可用房间 writeStringToResponse("1"); } else writeStringToResponse("0"); }
Example #17
Source File: SocialAuthenticationAction.java From socialauth with MIT License | 6 votes |
/** * creates a instance of the requested provider from AuthProviderFactory and * calls the getLoginRedirectURL() method to find the URL which the user * should be redirect to. * * @return String where the action should flow * @throws Exception * if an error occurs */ @Action(value = "/socialAuth") public String execute() throws Exception { LOG.info("Given provider id :: " + id); SASFHelper helper = SASFStaticHelper.getHelper(request); if (mode == null) { url = "http://opensource.brickred.com/socialauth-struts-filter-demo/SAF/SocialAuth?id=" + id; return "forward"; } else if ("signout".equals(mode)) { SocialAuthManager manager = null; if (helper != null) { manager = helper.getAuthManager(); if (manager != null) { manager.disconnectProvider(id); } } return "home"; } return "home"; }
Example #18
Source File: LoginAction.java From java-course-ee with MIT License | 5 votes |
@Override @Action(value = "login-screen", results = { @Result(name = "input", location = "login.jsp") }) public String input() throws Exception { return "input"; }
Example #19
Source File: SysRoleAction.java From EasyEE with MIT License | 5 votes |
/** * 获得所有权限的Id(菜单权限+操作权限),为了防止id重复,使用前缀标识 * @return */ @SuppressWarnings("rawtypes") @Action("getAllPermissionsId") public String getAllPermissionsId() { List<Map> all=sysRoleService.getAllPermissionsIds(sysRole.getRoleId()); List allPermissions=new ArrayList(); for (Map res : all) { allPermissions.add(res.get("TYPE")+"_"+res.get("ID")); } super.setJsonMap("list",allPermissions); // System.out.println("###############################:::"+allPermissions); return JSON; }
Example #20
Source File: CaptchaAction.java From EasyEE with MIT License | 5 votes |
/** * 验证码检测 * * @return */ @Action(value="/checkCaptcha") public String checkCaptcha() { HttpSession session = request.getSession(); if (!(session.getAttribute("rand") != null && session .getAttribute("rand").toString().equalsIgnoreCase(captcha))) { statusCode=StatusCode.ERROR; msg=getText("sys.LoginAction.captchatError"); } super.setJsonMsgMap(); return JSON; }
Example #21
Source File: SysRoleAction.java From EasyEE with MIT License | 5 votes |
/** * 删除角色 * * @return */ @Action("delete") public String delete() { try { sysRoleService.delete(sysRole.getRoleId()); super.reloadPermissions(); //刷新权限 } catch (Exception e) { e.printStackTrace(); statusCode=StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #22
Source File: DeptAction.java From EasyEE with MIT License | 5 votes |
/** * 转向显示页面 * @return */ @Action(value="page",results={ @Result(location="/WEB-INF/content/main/hr/Dept.jsp") }) public String page(){ return SUCCESS; }
Example #23
Source File: SocialAuthUploadPhotoAction.java From socialauth with MIT License | 5 votes |
/** * Update status for the given provider. * * @return String where the action should flow * @throws Exception * if an error occurs */ @Action(value="/socialAuthUploadPhotoAction") public String execute() throws Exception { SocialAuthManager manager = null; if (userSession.get("socialAuthManager") != null) { manager = (SocialAuthManager)userSession.get("socialAuthManager"); } AuthProvider provider = null; if(manager!=null){ provider = manager.getCurrentAuthProvider(); } if (provider != null) { try { provider.uploadImage(statusMessage, imageFileFileName, new FileInputStream(imageFile)); request.setAttribute("Message", "Status Updated successfully"); return "success"; } catch (SocialAuthException e) { request.setAttribute("Message", e.getMessage()); e.printStackTrace(); } } return "failure"; }
Example #24
Source File: SysUserAction.java From EasyEE with MIT License | 5 votes |
/** * 删除用户 * * @return */ @Action("delete") public String delete() { try { sysUserService.delete(userId); // sysUserService.delete(sysUser.getUserId()); } catch (Exception e) { e.printStackTrace(); // 出错输出 500 响应 // ServletActionContext.getResponse().setStatus(500); statusCode = StatusCode.ERROR; } super.setJsonMsgMap(); return JSON; }
Example #25
Source File: SysUserAction.java From EasyEE with MIT License | 5 votes |
/** * 添加用户 * * @return */ @SuppressWarnings("unchecked") @Action("save") public String save() { statusCode = StatusCode.ERROR; msg = getText("msg.saveFail"); if (sysUser.getPassword() != null && sysUser.getPassword().equals(confirmPwd)) { if (sysUserService.existsName(sysUser.getName())) { msg = getText("sys.UserAction.userExists"); } else { if(roleIds!=null){ for (String roleId : roleIds) { // 保存角色 sysUser.getSysRoles().add(new SysRole(Integer.valueOf(roleId))); } } // 保存用户 try { sysUser.setPassword(MD5.getMd5(sysUser.getPassword(), sysUser.getName().toLowerCase())); sysUserService.add(sysUser); msg = getText("msg.saveSuccess"); statusCode = StatusCode.OK; msg = ""; // 跳转到最后一页 super.page = sysUserService.findMaxPage(rows); } catch (Exception e) { logger.error(getText("sys.UserAction.saveException"), e); } } } else { msg = getText("sys.UserAction.pwdNotEqauals"); } super.setJsonMsgMap("page", super.page); return JSON; }
Example #26
Source File: SysUserAction.java From EasyEE with MIT License | 5 votes |
@Override @Action(value="page",results={ @Result(location="/WEB-INF/content/main/sys/sysUser.jsp") }) public String execute() throws Exception { return SUCCESS; }
Example #27
Source File: DeptAction.java From EasyEE with MIT License | 5 votes |
@Action("update") public String update(){ try { deptService.update(dept); msg=getText("msg.updateSuccess"); } catch (Exception e) { e.printStackTrace(); msg=getText("msg.updateFail"); statusCode=StatusCode.ERROR; } setJsonMsgMap(); return JSON; }
Example #28
Source File: DeptAction.java From EasyEE with MIT License | 5 votes |
/** * 分页 * @return */ @SuppressWarnings("rawtypes") @Action("list") public String list(){ PageBean pb = super.getPageBean(); // 获得分页对 deptService.findByPage(pb,deptCriteria); // EasyUI框架响应结果都是JSON // JSON数据初始化,包含EasySSH Ajax响应信息和分页信息 super.setJsonPaginationMap(pb); return JSON; }
Example #29
Source File: DeptAction.java From EasyEE with MIT License | 5 votes |
/** * CRUD * @return */ @Action("save") public String save(){ // 保存 try { deptService.save(dept); // 处理成功 消息 msg = getText("msg.saveSuccess"); // 如果需要刷新,跳转到最后一页 // super.page = deptService.findMaxPage(rows); } catch (Exception e) { e.printStackTrace(); msg = getText("msg.saveFail"); statusCode=StatusCode.ERROR; //默认为OK } /* * Ajax响应信息 * statusCode: 响应状态码; * msg: 响应消息; * callback: 执行回调函数, * locationUrl: 跳转页面 */ // EasyUI框架响应结果都是JSON // JSON数据初始化,包含EasySSH Ajax响应信息 // super.setJsonMsgMap(); // 添加数据后,使用rowData信息更新行的内容 super.setJsonMsgMap("rowData", dept); // 返回JSON return JSON; }
Example #30
Source File: UserAction.java From Resource with GNU General Public License v3.0 | 5 votes |
@Action(value = "login", results = { @Result(name = "success", location = "/success.jsp", params = {"resultJson", "resultJson"}), @Result(name = "error", location = "/error.jsp")}) public String execute() throws Exception { HttpServletResponse response = ServletActionContext.getResponse(); HttpServletRequest request = ServletActionContext.getRequest(); JSONObject result = new JSONObject(); User user = userService.getByName(username); result.put("user", user); if (user != null && user.getUser_name().equals(username) && user.getPassword().equals(password)) { result.put("message", "登录成功"); result.put("status", "true"); resultJson = result.toString(); request.setAttribute("resultJson", resultJson); writeResponseData(request, response, result); return "success"; } result.put("message", "登录失败"); result.put("status", "false"); resultJson = result.toString(); writeResponseData(request, response, result); return "error"; }