List of usage examples for javax.servlet.http HttpServletRequest removeAttribute
public void removeAttribute(String name);
From source file:com.glaf.base.modules.sys.springmvc.UserController.java
/** * ?//w w w. j a va 2 s. c o m * * @param request * @param modelMap * @return */ @RequestMapping(params = "method=prepareModifyInfo") public ModelAndView prepareModifyInfo(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("parent"); SysUser user = RequestUtil.getLoginUser(request); SysUser bean = sysUserService.findByAccount(user.getAccount()); request.setAttribute("bean", bean); if (bean != null && StringUtils.isNotEmpty(bean.getSuperiorIds())) { List<String> userIds = StringTools.split(bean.getSuperiorIds()); StringBuffer buffer = new StringBuffer(); if (userIds != null && !userIds.isEmpty()) { for (String userId : userIds) { SysUser u = sysUserService.findByAccount(userId); if (u != null) { buffer.append(u.getName()).append("[").append(u.getAccount()).append("] "); } } request.setAttribute("x_users_name", buffer.toString()); } } String x_view = ViewProperties.getString("identity.user.prepareModifyInfo"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/identity/user/user_change_info", modelMap); }
From source file:com.opencnc.controllers.UsuarioController.java
/** * ***************************************************************************** * Cambia la contrasea./*w ww.ja va 2s . c o m*/ * ***************************************************************************** * ***************************************************************************** * Metodo aun si desarrollo. * ***************************************************************************** * @param request * @param response * @return * @throws IOException */ @RequestMapping("usuario/cambiarContrasena") public ModelAndView cambiarContrasena(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession sess = request.getSession(); if (sess != null) { ModelAndView m = new ModelAndView(); return m; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.glaf.base.modules.sys.springmvc.UserController.java
/** * ??/* w w w . j av a 2s. c o m*/ * * @param request * @param modelMap * @return */ @RequestMapping(params = "method=view") public ModelAndView view(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("parent"); String actorId = request.getParameter("actorId"); SysUser bean = sysUserService.findByAccount(actorId); request.setAttribute("bean", bean); if (bean != null && StringUtils.isNotEmpty(bean.getSuperiorIds())) { List<String> userIds = StringTools.split(bean.getSuperiorIds()); StringBuffer buffer = new StringBuffer(); if (userIds != null && !userIds.isEmpty()) { for (String userId : userIds) { SysUser u = sysUserService.findByAccount(userId); if (u != null) { buffer.append(u.getName()).append("[").append(u.getAccount()).append("] "); } } request.setAttribute("x_users_name", buffer.toString()); } } SysTree parent = sysTreeService.getSysTreeByCode(Constants.TREE_DEPT); List<SysTree> list = new java.util.ArrayList<SysTree>(); parent.setDeep(0); list.add(parent); sysTreeService.loadSysTrees(list, parent.getId(), 1); request.setAttribute("parent", list); String x_view = ViewProperties.getString("user.view"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/identity/user/user_view", modelMap); }
From source file:com.glaf.base.modules.sys.springmvc.SysDictoryController.java
/** * ?/*from w w w. j a v a 2s . co m*/ * * @param request * @param modelMap * @return */ @RequestMapping(params = "method=prepareModify") public ModelAndView prepareModify(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("parent"); long id = ParamUtil.getIntParameter(request, "id", 0); Dictory bean = dictoryService.find(id); request.setAttribute("bean", bean); long nodeId = ParamUtil.getLongParameter(request, "parent", 0); if (bean != null && bean.getNodeId() > 0) { nodeId = bean.getNodeId(); } if (nodeId > 0) { List<DictoryDefinition> list = dictoryDefinitionService.getDictoryDefinitions(nodeId, "sys_dictory"); if (list != null && !list.isEmpty()) { if (bean != null) { Map<String, Object> dataMap = Tools.getDataMap(bean); for (DictoryDefinition d : list) { Object value = dataMap.get(d.getName()); d.setValue(value); } } Collections.sort(list); request.setAttribute("list", list); } } if (bean == null) { SysTree parent = sysTreeService.getSysTreeByCode(Constants.TREE_DICTORY); List<SysTree> list = new java.util.ArrayList<SysTree>(); parent.setDeep(0); list.add(parent); sysTreeService.loadSysTrees(list, parent.getId(), 1); request.setAttribute("parent", list); } String x_view = ViewProperties.getString("dictory.prepareModify"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/sys/dictory/dictory_modify", modelMap); }
From source file:com.glaf.oa.assesscontent.web.springmvc.AssesscontentController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Assesscontent assesscontent = assesscontentService .getAssesscontent(RequestUtils.getLong(request, "contentid")); if (assesscontent != null) { request.setAttribute("assesscontent", assesscontent); JSONObject rowJSON = assesscontent.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }/* w w w . java 2s .c om*/ boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (assesscontent != null) { // if (assesscontent.getStatus() == 0 || // assesscontent.getStatus() == -1) { canUpdate = true; // } } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("assesscontent.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/assesscontent/edit", modelMap); }
From source file:com.glaf.base.modules.sys.springmvc.SysDictoryController.java
/** * ?// ww w .j a v a 2s.c o m * * @param request * @param modelMap * @return */ @RequestMapping(params = "method=prepareAdd") public ModelAndView prepareAdd(HttpServletRequest request, ModelMap modelMap) { // ? RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("parent"); Map<String, Object> params = RequestUtils.getParameterMap(request); Long nodeId = ParamUtils.getLong(params, "parent"); if (nodeId > 0) { List<DictoryDefinition> list = dictoryDefinitionService.getDictoryDefinitions(nodeId, "sys_dictory"); if (list != null && !list.isEmpty()) { Collections.sort(list); request.setAttribute("list", list); } } String x_view = ViewProperties.getString("dictory.prepareAdd"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/sys/dictory/dictory_add", modelMap); }
From source file:com.opencnc.controllers.SentenciaController.java
/** * ***************************************************************************** * Borra la sentencia creada./*from w ww .j a va 2 s . c o m*/ * ***************************************************************************** * @param id * @param request * @param response * @return * @throws Exception */ @RequestMapping("/sentencia/borrar/{id}") public ModelAndView borrar(@PathVariable Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession sess = request.getSession(); if (sess != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Sentencia e = (Sentencia) s.get(Sentencia.class, id); Transaction t = s.beginTransaction(); s.delete(e); t.commit(); return null; } else { request.removeAttribute("usuario"); return new ModelAndView("redirect:/usuario/login.htm"); } }
From source file:com.ibm.jaggr.core.test.TestUtils.java
public static HttpServletRequest createMockRequest(IAggregator aggregator, final Map<String, Object> requestAttributes, final Map<String, String[]> requestParameters, final Cookie[] cookies, final Map<String, String> headers) { HttpServletRequest mockRequest = EasyMock.createNiceMock(HttpServletRequest.class); if (requestAttributes != null) { requestAttributes.put(IAggregator.AGGREGATOR_REQATTRNAME, aggregator); EasyMock.expect(mockRequest.getAttribute((String) EasyMock.anyObject())) .andAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { return requestAttributes.get((String) EasyMock.getCurrentArguments()[0]); }/*from w w w . j a v a 2 s. co m*/ }).anyTimes(); mockRequest.setAttribute((String) EasyMock.anyObject(), EasyMock.anyObject()); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { String name = (String) EasyMock.getCurrentArguments()[0]; Object value = EasyMock.getCurrentArguments()[1]; requestAttributes.put(name, value); return null; } }).anyTimes(); mockRequest.removeAttribute((String) EasyMock.anyObject()); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { String name = (String) EasyMock.getCurrentArguments()[0]; requestAttributes.remove(name); return null; } }).anyTimes(); } else { EasyMock.expect(mockRequest.getAttribute(IAggregator.AGGREGATOR_REQATTRNAME)).andReturn(aggregator) .anyTimes(); } if (requestParameters != null) { EasyMock.expect(mockRequest.getParameter((String) EasyMock.anyObject())) .andAnswer(new IAnswer<String>() { public String answer() throws Throwable { String[] ary = requestParameters.get((String) EasyMock.getCurrentArguments()[0]); return ary != null && ary.length > 0 ? ary[0] : null; } }).anyTimes(); EasyMock.expect(mockRequest.getParameterMap()).andAnswer(new IAnswer<Map<String, String[]>>() { @Override public Map<String, String[]> answer() throws Throwable { return requestParameters; } }).anyTimes(); } if (cookies != null) { EasyMock.expect(mockRequest.getCookies()).andAnswer(new IAnswer<Cookie[]>() { public Cookie[] answer() throws Throwable { return cookies; } }).anyTimes(); } if (headers != null) { EasyMock.expect(mockRequest.getHeader((String) EasyMock.anyObject())).andAnswer(new IAnswer<String>() { public String answer() throws Throwable { return headers.get((String) EasyMock.getCurrentArguments()[0]); } }).anyTimes(); } return mockRequest; }
From source file:org.kmnet.com.fw.web.logging.TraceLoggingInterceptor.java
/** * Logic to output end log// w w w . ja v a 2 s . c o m * <p> * Outputs the end log.<br> * Outputs warning log if difference of time between start time and end time is more than the nano-seconds value<br> * set as warning log output timing. * </p> * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#postHandle(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.web.servlet.ModelAndView) */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { if (!(handler instanceof HandlerMethod)) { return; } long startTime = 0; if (request.getAttribute(START_ATTR) != null) { startTime = ((Long) request.getAttribute(START_ATTR)).longValue(); } long handlingTime = System.nanoTime() - startTime; request.removeAttribute(START_ATTR); request.setAttribute(HANDLING_ATTR, handlingTime); String formattedHandlingTime = String.format("%1$,3d", handlingTime); boolean isWarnHandling = (handlingTime > warnHandlingNanos); if (isWarnHandling) { if (!logger.isWarnEnabled()) { return; } } else if (!logger.isTraceEnabled()) { return; } HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); Object view = null; Map<String, Object> model = null; if (modelAndView != null) { view = modelAndView.getView(); model = modelAndView.getModel(); if (view == null) { view = modelAndView.getViewName(); } } logger.trace("[END CONTROLLER ] {}.{}({})-> view={}, model={}", new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), view, model }); String handlingTimeMessage = "[HANDLING TIME ] {}.{}({})-> {} ns"; if (isWarnHandling) { logger.warn(handlingTimeMessage + " > {}", new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), formattedHandlingTime, warnHandlingNanos }); } else { logger.trace(handlingTimeMessage, new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod), formattedHandlingTime }); } }
From source file:com.glaf.chart.web.springmvc.ChartController.java
@RequestMapping("/chooseQuery") public ModelAndView chooseQuery(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Map<String, Object> params = RequestUtils.getParameterMap(request); String rowId = ParamUtils.getString(params, "chartId"); QueryDefinitionQuery query = new QueryDefinitionQuery(); List<QueryDefinition> list = queryDefinitionService.list(query); request.setAttribute("unselecteds", list); Chart chart = null;/*from w w w.j a v a2 s . c om*/ if (StringUtils.isNotEmpty(rowId)) { chart = chartService.getChart(rowId); request.setAttribute("chart", chart); if (StringUtils.isNotEmpty(chart.getQueryIds())) { StringBuffer sb01 = new StringBuffer(); StringBuffer sb02 = new StringBuffer(); List<String> selecteds = new java.util.ArrayList<String>(); for (QueryDefinition q : list) { if (StringUtils.contains(chart.getQueryIds(), q.getId())) { selecteds.add(q.getId()); sb01.append(q.getId()).append(","); sb02.append(q.getName()).append(","); } } if (sb01.toString().endsWith(",")) { sb01.delete(sb01.length() - 1, sb01.length()); } if (sb02.toString().endsWith(",")) { sb02.delete(sb02.length() - 1, sb02.length()); } request.setAttribute("selecteds", selecteds); request.setAttribute("queryIds", sb01.toString()); request.setAttribute("queryNames", sb02.toString()); } } String x_view = ViewProperties.getString("chart.chooseQuery"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/bi/chart/chooseQuery", modelMap); }