Java Code Examples for javax.servlet.http.HttpServletRequest.getParameterValues()

The following are Jave code examples for showing how to use getParameterValues() of the javax.servlet.http.HttpServletRequest class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: joai-project   File: JSHTMLAction_1_1.java   View Source Code Vote up 6 votes
private HashMap configureCustomMenus(HttpServletRequest request, JSHTMLForm_1_1 form) {
	String[] menus = request.getParameterValues("menu");
	if (menus == null || menus.length == 0)
		return null;

	HashMap searchMappings = new HashMap(menus.length);
	HashMap menuItemsMap = new HashMap(menus.length);
	for (int i = 0; i < menus.length; i++) {
		//prtln("menu: " + menus[i]);
		String[] vals = menus[i].split("\\|");
		if (vals == null || vals.length != 3)
			continue;

		// Form: menuName | itemName | query
		Object position = form.addMenuItem(vals[0], vals[1]);
		String key = "slm" + position + "-" + (form.getNumMenuItems(vals[0]) -1 );
		searchMappings.put(key, vals[2]);
		menuItemsMap.put(key, vals[1]);
		//prtln("menu key: " + key + " menu: " + vals[0] + " item: " + vals[1]);
	}
	form.setMenuItemsMap(menuItemsMap);
	return searchMappings;
}
 
Example 2
Project: zhkuas_ssm_maven   File: SchoolAccountController.java   View Source Code Vote up 6 votes
@RequestMapping(value="/account/users",method=RequestMethod.PUT)
@ResponseBody
public Map<String,Object> unBind(HttpServletRequest request){
	String [] uids =request.getParameterValues("uid[]");
	try{
		List<User> users = new ArrayList<User>();
		for(String strId:uids){
			int id = Integer.valueOf(strId);
			User user = userService.getUserById(id);
			if(user==null){
				return WebUtils.webJsonError("没有找到uid为"+id+"的用户!");
			}
			if(user.getStudent()!=null){
				user.getStudent().setsNo(null);
				userService.updateUser(user);
				user.setStudent(null);
				users.add(user);
			}
		}
		return WebUtils.webJsonResult(users);
	}catch (Exception e) {
		return WebUtils.webJsonError(Error.PARAMETER_ERROR);
	}
}
 
Example 3
Project: bfmvc   File: ParameterUtil.java   View Source Code Vote up 6 votes
private static List<FormParam> parseParameterNames(HttpServletRequest request) {
    List<FormParam> formParams = new ArrayList<>();
    //将发送请求页面中form表单所具有name属性的表单对象获取
    Enumeration<String> paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String fieldName = paramNames.nextElement();
        String[] fieldValues = request.getParameterValues(fieldName);
        if (ArrayUtil.isNotEmpty(fieldValues)) {
            Object fieldValue;
            if (fieldValues.length == 1) {
                fieldValue = fieldValues[0];
            } else {
                StringBuilder sb = new StringBuilder("");
                for (int i = 0; i < fieldValues.length; ++i) {
                    sb.append(fieldValues[i]);
                    if (i != fieldValues.length - 1) {
                        sb.append(StringUtil.separator);
                    }
                }
                fieldValue = sb.toString();
            }
            formParams.add(new FormParam(fieldName, fieldValue));
        }
    }
    return formParams;
}
 
Example 4
Project: lams   File: GradebookMonitoringAction.java   View Source Code Vote up 5 votes
/**
    * Exports selected lessons Gradebook into excel.
    */
   public ActionForward exportExcelSelectedLessons(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws Exception {
Integer organisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
UserDTO user = getUser();
if (!getSecurityService().isGroupMonitor(organisationID, user.getUserID(),
	"export selected lessons gradebook spreadsheet", false)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the organisation");
    return null;
}

boolean simplified = WebUtil.readBooleanParam(request, "simplified", false);

Organisation organisation = (Organisation) getUserService().findById(Organisation.class, organisationID);
String[] lessonIds = request.getParameterValues(AttributeNames.PARAM_LESSON_ID);
if (GradebookMonitoringAction.log.isDebugEnabled()) {
    GradebookMonitoringAction.log.debug("Exporting to a spreadsheet lessons " + Arrays.toString(lessonIds)
	    + " from course: " + organisationID);
}
LinkedHashMap<String, ExcelCell[][]> dataToExport = getGradebookService()
	.exportSelectedLessonsGradebook(user.getUserID(), organisationID, lessonIds, simplified);

String fileName = organisation.getName().replaceAll(" ", "_") + ".xlsx";
fileName = FileUtil.encodeFilenameForDownload(request, fileName);

response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);

// set cookie that will tell JS script that export has been finished
String downloadTokenValue = WebUtil.readStrParam(request, "downloadTokenValue");
Cookie fileDownloadTokenCookie = new Cookie("fileDownloadToken", downloadTokenValue);
fileDownloadTokenCookie.setPath("/");
response.addCookie(fileDownloadTokenCookie);

// Code to generate file and write file contents to response
ServletOutputStream out = response.getOutputStream();
ExcelUtil.createExcel(out, dataToExport, null, false);

return null;
   }
 
Example 5
Project: teamcity-msteams-notifier   File: MsTeamsNotificationTestServer.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
private void printParams(HttpServletRequest request, HttpServletResponse response){
	PrintWriter out = null;
	try {
		out = response.getWriter();
	} catch (IOException e) {
		e.printStackTrace();
	}
	Enumeration<String> paramNames = request.getParameterNames();

    while(paramNames.hasMoreElements()) {
      String paramName = paramNames.nextElement();
      out.print(paramName + " :: ");
      String[] paramValues = request.getParameterValues(paramName);
      if (paramValues.length == 1) {
        String paramValue = paramValues[0];
        if (paramValue.length() == 0)
          out.println("No Value");
        else
          out.println(paramValue);
      } else {
    	  out.println();
        for(int i=0; i<paramValues.length; i++) {
          out.println(" ->  " + paramValues[i]);
        }
      }
    }

}
 
Example 6
Project: incubator-servicecomb-java-chassis   File: QueryProcessorCreator.java   View Source Code Vote up 5 votes
@Override
public Object getValue(HttpServletRequest request) throws Exception {
  Object value = null;
  if (targetType.isContainerType()) {
    value = request.getParameterValues(paramPath);
  } else {
    value = request.getParameter(paramPath);
  }

  return convertValue(value, targetType);
}
 
Example 7
Project: webpoll   File: NewMultiplechoiceQuestionServlet.java   View Source Code Vote up 5 votes
/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	// Check for valid name. valid ? redirect("/surveybuilder") : redirect("/newmultiplechoicequestion")
	// Check for atleast one option.
	CreateSurveySessionManager session = new CreateSurveySessionManager(request);
	
	if (securityService.isLoggedIn()) {
		if (session.hasSurveyModel()) {

			String[] options = request.getParameterValues("option");
			boolean canHaveMultipleAnswers = request.getParameter("canhavemultipleanswers") != null;
			String name = request.getParameter("questionname");
			QuestionCreationModel newQuestion = new QuestionCreationModel(options, canHaveMultipleAnswers, name);

			if (newQuestion.hasQuestionText()) {
				if (newQuestion.hasAtleastOneOption()) {
					session.getSurveyModel().addQuestionCreationModel(newQuestion);
					response.sendRedirect("surveybuilder");
					session.clearErrorMessages();
				} else {
					session.setErrorMessage(ErrorMessage.MULTIPLECHOICE_QUESTION_DOES_NOT_HAVE_ATLEAST_ONE_OPTION);
					response.sendRedirect("newmultiplechoicequestion");
				}
			} else {
				session.setErrorMessage(ErrorMessage.NAME_CAN_NOT_BE_EMPTY);
				response.sendRedirect("newmultiplechoicequestion");
			}
			
		} else {
			response.sendRedirect("lecturer");
			session.clearErrorMessages();
		}
	} else {
		session.setErrorMessage(ErrorMessage.NOT_LOGGED_IN);
		response.sendRedirect("index");
	}
}
 
Example 8
Project: shuzheng   File: UpmsUserController.java   View Source Code Vote up 5 votes
@ApiOperation(value = "用户角色")
@RequiresPermissions("upms:user:role")
@RequestMapping(value = "/role/{id}", method = RequestMethod.POST)
@ResponseBody
public Object role(@PathVariable("id") int id, HttpServletRequest request) {
    String[] roleIds = request.getParameterValues("roleId");
    upmsUserRoleService.role(roleIds, id);
    return new UpmsResult(UpmsResultConstant.SUCCESS, "");
}
 
Example 9
Project: tianti   File: CmsController.java   View Source Code Vote up 5 votes
/**
 * 文章置顶
 * @param request
 * @return
 */
@RequestMapping("/article/ajax/top")
@ResponseBody
public AjaxResult ajaxArticleTop(HttpServletRequest request){
	AjaxResult ajaxResult = new AjaxResult();
	ajaxResult.setSuccess(false);
	
	try {
		Boolean isTop = false;
		String[] ids = request.getParameterValues("ids");
		String topFlag = request.getParameter("topFlag");
		if(StringUtils.isNotBlank(topFlag) && topFlag.equals("1")){
			isTop = true;
		}
		if(ids != null && ids.length > 0){
			for(String id:ids){
				Article article = this.articleService.find(id);
				article.setIsTop(isTop);
				this.articleService.update(article);
			}
		}
		ajaxResult.setSuccess(true);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return ajaxResult;
}
 
Example 10
Project: tianti   File: CmsController.java   View Source Code Vote up 5 votes
/**
 * 栏目删除
 * @param request
 * @return
 */
@RequestMapping("/column/ajax/delete")
@ResponseBody
public AjaxResult ajaxUpdColumnDelete(HttpServletRequest request){
	AjaxResult ajaxResult = new AjaxResult();
	ajaxResult.setSuccess(false);
	
	try {
		String[] ids = request.getParameterValues("ids");
		String deleteFlag = request.getParameter("deleteFlag");
		
		if(ids != null && ids.length > 0){
			for(String id:ids){
				ColumnInfo columnInfo = this.columnInfoService.find(id);
				columnInfo.setDeleteFlag(deleteFlag);
				this.columnInfoService.update(columnInfo);
				
				//删除该节点对应的孩子列表
				ColumnInfoQueryDTO columnInfoQueryDTO = new ColumnInfoQueryDTO();
				columnInfoQueryDTO.setRootColumnId(id);
				List<ColumnInfo> leafColumnInfoList = this.columnInfoService.queryColumnInfoList(columnInfoQueryDTO);
				if(leafColumnInfoList != null && leafColumnInfoList.size() > 0){
					for(ColumnInfo c : leafColumnInfoList){
						c.setDeleteFlag(ColumnInfo.DELETE_FLAG_DELETED);
						this.columnInfoService.update(c);
					}
				}
			}
		}
		ajaxResult.setSuccess(true);
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	return ajaxResult;
}
 
Example 11
Project: sjk   File: CatalogConvertorController.java   View Source Code Vote up 5 votes
private List<CatalogConvertor> catalogStrToList(HttpServletRequest request) throws Exception {
    String[] ids = request.getParameterValues("id");
    String[] marketNames = request.getParameterValues("marketName");
    String[] catalogs = request.getParameterValues("catalog");
    String[] subCatalogs = request.getParameterValues("subCatalog");
    String[] subCatalogNames = request.getParameterValues("subCatalogName");
    String[] targetCatalogs = request.getParameterValues("targetCatalog");
    String[] targetSubCatalogs = request.getParameterValues("targetSubCatalog");
    int len = 0;
    if (ids != null)
        len = ids.length;
    List<CatalogConvertor> list = new ArrayList<CatalogConvertor>();
    for (int i = 0; i < len; i++) {
        if (Integer.valueOf(targetSubCatalogs[i]) > 0 && Short.valueOf(targetCatalogs[i]) > 0) {
            CatalogConvertor catalog = new CatalogConvertor(marketNames[i], Short.parseShort(catalogs[i]),
                    Integer.parseInt(subCatalogs[i]), subCatalogNames[i], Short.parseShort(targetCatalogs[i]),
                    Integer.parseInt(targetSubCatalogs[i]));

            catalog.setId(Integer.valueOf(StringUtils.defaultIfBlank(ids[i], "0")));
            if (validateModels(catalog)) {
                list.add(catalog);
            } else {
                throw new Exception("数据错误,确认数据完整性!");
            }
        }
    }
    return list;
}
 
Example 12
Project: joai-project   File: DDSServicesAction.java   View Source Code Vote up 5 votes
/**
 *  Handles a request to check the repository for the existence of a given URL. <p>
 *
 *  Arguments: url (one or more} <p>
 *
 *  Error Exception Conditions: <br>
 *  badArgument - The request includes illegal arguments.
 *
 * @param  request   The HTTP request
 * @param  response  The HTTP response
 * @param  rm        The RepositoryManager used
 * @param  df        The bean
 * @param  mapping   ActionMapping used
 * @return           An ActionForward to the JSP page that will handle the response
 */
protected ActionForward doUrlCheck(
                                   HttpServletRequest request,
                                   HttpServletResponse response,
                                   RepositoryManager rm,
                                   DDSServicesForm df,
                                   ActionMapping mapping) {

	String[] urls = request.getParameterValues("url");
	if (urls == null || urls.length == 0) {
		df.setErrorMsg("You must supply one or more url parameters for the UrlCheck request.");
		df.setErrorCode(DDSServicesForm.ERROR_CODE_BADARGUMENT);
		return mapping.findForward("ddsservices.error");
	}

	String q = "urlenc:" + SimpleLuceneIndex.encodeToTerm(urls[0].trim(), false);
	for (int i = 1; i < urls.length; i++) {
		q += " OR urlenc:" + SimpleLuceneIndex.encodeToTerm(urls[i].trim(), false);
	}

	SimpleLuceneIndex index = rm.getIndex();
	ResultDocList resultDocs = index.searchDocs(q);

	//prtln("doUrlCheck() search for: '" + q + "' had " + (resultDocs == null ? -1 : resultDocs.length) + " resultDocs");

	if (resultDocs == null || resultDocs.size() == 0) {
		df.setResults(null);
	}
	else {
		df.setResults(resultDocs);
	}

	return (mapping.findForward("ddsservices.UrlCheck"));
}
 
Example 13
Project: joai-project   File: RepositoryAction.java   View Source Code Vote up 5 votes
/**
 *  Gets the nonValidRequestArguments, or null if none were found.
 *
 * @param  request  The HttpServletRequest
 */
private boolean validateRequestArguments(HttpServletRequest request, RepositoryForm rf) {
	boolean hasNonValidArg = false;
	
	if (validArgsMap == null) {
		validArgsMap = new HashMap(8);
		validArgsMap.putAll(OAIArgs.ALL_VALID_OAI_ARGUMENTS_MAP);

		// Allow the rt argument, used in the webapps to validate OAI responses
		validArgsMap.put("rt", "rt");
	}

	String msg = "The following request arguments are not valid for OAI-PMH: ";		
	Enumeration params = request.getParameterNames();
	while (params.hasMoreElements()) {
		
		// Check if the arg is valid in OAI-PMH:
		String param = (String) params.nextElement();
		if (!validArgsMap.containsKey(param)) {
			msg += (hasNonValidArg ? ", " : " ") + param;
			hasNonValidArg = true;
		}
		// Verify that the arg does not repeat:
		else if (request.getParameterValues(param).length > 1) {
			msg += (hasNonValidArg ? ", " : " ") + param + " (repeated not allowed)";
			hasNonValidArg = true;
		}			
	}
	
	// Write the error message and code:
	if(hasNonValidArg)
		rf.addOaiError(OAICodes.BAD_ARGUMENT, msg);

	return hasNonValidArg;
}
 
Example 14
Project: sgroup   File: BootstrapProductServlet.java   View Source Code Vote up 5 votes
/**
 * 批量删除功能
 * @param req 客户端发送的数据封装类
 * @param resp 服务器发送的数据封装类(大概)
 */
private void mulDel(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String[] strPids = req.getParameterValues("check_product");
    Integer[] pids = new Integer[strPids.length];
    for (int i = 0; i<pids.length; i++) {
        pids[i] = Integer.parseInt(strPids[i]);
    }
    int result = productService.delMulProduct(pids);
    PrintWriter out = resp.getWriter();
    if (result > 0) {
        resp.sendRedirect("/productservlet.do?operate=product");
    } else {
        out.print("<script>alert('删除失败!');history.back();</script>");
    }
}
 
Example 15
Project: tianti   File: UserController.java   View Source Code Vote up 4 votes
/**
 * 保存角色
 * @param request
 * @return
 */
@RequestMapping("/ajax/save_role")
@ResponseBody
public AjaxResult ajaxSaveRole(HttpServletRequest request){
	AjaxResult ajaxResult = new AjaxResult();
	ajaxResult.setSuccess(false);
	
	try {
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String description = request.getParameter("description");
		String[] rescoureIds = request.getParameterValues("rescoureIds");
		
		
		Role role = null;
		if(StringUtils.isNotBlank(id)){
			role = roleService.get(id);
		}else{
			role = new Role();
		}
		
		role.setName(StringUtils.trim(name));
		role.setDescription(StringUtils.trim(description));
		
		Set<Resource> resources = new HashSet<Resource>();
		if(rescoureIds != null){
			for(String rId : rescoureIds){
				Resource resource = resourceService.find(rId);
				if(resource != null){
					resources.add(resource);
				}
			}
		}
		role.setResources(resources);
		
		if(StringUtils.isNotBlank(role.getId())){
			roleService.update(role);
		}else{
			roleService.save(role);
		}
		
		ajaxResult.setSuccess(true);
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	return ajaxResult;
}
 
Example 16
Project: xmanager   File: UeditorService.java   View Source Code Vote up 4 votes
private String invoke(HttpServletRequest request) {
	String actionType = request.getParameter("action");
	String rootPath = request.getServletContext().getRealPath("/");
	String ctxPath  = request.getContextPath();
	
	if (actionType == null || !ActionMap.mapping.containsKey(actionType)) {
		return new BaseState(false, AppInfo.INVALID_ACTION).toJSONString();
	}
	if (ueditorManager == null || !ueditorManager.valid()) {
		return new BaseState(false, AppInfo.CONFIG_ERROR).toJSONString();
	}

	IUeditorFileManager fileManager = ueditorManager.getFileManager();
	
	State state = null;
	int actionCode = ActionMap.getType(actionType);
	ActionConfig conf = null;

	switch (actionCode) {

	case ActionMap.CONFIG:
		UeditorConfig allConfig = ueditorManager.getConfig();
		String imageUrlPrefix = allConfig.getImageUrlPrefix();
		String scrawlUrlPrefix = allConfig.getScrawlUrlPrefix();
		String snapscreenUrlPrefix = allConfig.getSnapscreenUrlPrefix();
		String catcherUrlPrefix = allConfig.getCatcherUrlPrefix();
		String videoUrlPrefix = allConfig.getVideoUrlPrefix();
		String fileUrlPrefix = allConfig.getFileUrlPrefix();
		String imageManagerUrlPrefix = allConfig.getImageManagerUrlPrefix();
		String fileManagerUrlPrefix = allConfig.getFileManagerUrlPrefix();

		if (StringUtils.isBlank(imageUrlPrefix)) {
			allConfig.setImageUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(scrawlUrlPrefix)) {
			allConfig.setScrawlUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(snapscreenUrlPrefix)) {
			allConfig.setSnapscreenUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(catcherUrlPrefix)) {
			allConfig.setCatcherUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(videoUrlPrefix)) {
			allConfig.setVideoUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(fileUrlPrefix)) {
			allConfig.setFileUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(imageManagerUrlPrefix)) {
			allConfig.setImageManagerUrlPrefix(ctxPath);
		}
		if (StringUtils.isBlank(fileManagerUrlPrefix)) {
			allConfig.setFileManagerUrlPrefix(ctxPath);
		}
		return JsonUtils.toJson(allConfig);

	case ActionMap.UPLOAD_IMAGE:
	case ActionMap.UPLOAD_SCRAWL:
	case ActionMap.UPLOAD_VIDEO:
	case ActionMap.UPLOAD_FILE:
		conf = ueditorManager.getConfig(actionCode, rootPath);
		state = new Uploader(request, conf).doExec(fileManager);
		break;

	case ActionMap.CATCH_IMAGE:
		conf = ueditorManager.getConfig(actionCode, rootPath);
		String[] list = request.getParameterValues(conf.getFieldName());
		state = new ImageHunter(fileManager, conf).capture(list);
		break;

	case ActionMap.LIST_IMAGE:
	case ActionMap.LIST_FILE:
		conf = ueditorManager.getConfig(actionCode, rootPath);
		int start = getStartIndex(request);
		state = fileManager.list(conf, start);
		break;

	}
	return state.toJSONString();
}
 
Example 17
Project: joai-project   File: CATServiceHelper.java   View Source Code Vote up 4 votes
/**
 *  Sets various control attributes from the information contained in the
 *  request, such as displayMode, displayContent, and whether description,
 *  grade ranges, subjects, keywords, will be used in the CAT Service request.
 *
 * @param  request        NOT YET DOCUMENTED
 * @exception  Exception  NOT YET DOCUMENTED
 */
public void updateDisplayControls(HttpServletRequest request)
	 throws Exception {
	String pathArg = request.getParameter("pathArg");
	String command = request.getParameter("command");
	try {

		String displayMode = request.getParameter("displayMode");
		if (displayMode != null) {
			setDisplayMode(displayMode);
		}

		String displayContent = request.getParameter("displayContent");
		if (displayContent != null) {
			setDisplayContent(displayContent);
		}

		String useDescription = request.getParameter("useDescription");
		if (useDescription != null && useDescription.trim().length() > 0) {
			setUseDescription(true);
		}
		else {
			setUseDescription(false);
		}

		String useKeywords = request.getParameter("useKeywords");
		if (useKeywords != null && useKeywords.trim().length() > 0) {
			setUseKeywords(true);
		}
		else {
			setUseKeywords(false);
		}

		String keywords = request.getParameter("keywords");
		setSelectedKeywords((keywords == null) ? "" : keywords);

		String useGradeRanges = request.getParameter("useGradeRanges");
		if (useGradeRanges != null && useGradeRanges.trim().length() > 0) {
			setUseGradeRanges(true);
		}
		else {
			setUseGradeRanges(false);
		}

		String[] gradeRanges = request.getParameterValues("gradeRanges");
		setSelectedGradeRanges((gradeRanges == null) ? new String[]{} : gradeRanges);

		String useSubjects = request.getParameter("useSubjects");
		if (useSubjects != null && useSubjects.trim().length() > 0) {
			setUseSubjects(true);
		}
		else {
			setUseSubjects(false);
		}

	} catch (Throwable t) {
		String errorMsg = "updateDisplayControls ERROR: " + t.getMessage();
		throw new Exception(errorMsg);
	}
}
 
Example 18
Project: ssm-web   File: BaseController.java   View Source Code Vote up 4 votes
protected String[] getParameters(HttpServletRequest request, String param) {
    String[] values = request.getParameterValues(param);
    return values;
}
 
Example 19
Project: tianti   File: UserController.java   View Source Code Vote up 4 votes
/**
 * 用户保存操作
 * @param request
 * @return
 */
@RequestMapping("/ajax/save")
@ResponseBody
public AjaxResult ajaxSave(HttpServletRequest request){
	AjaxResult ajaxResult = new AjaxResult();
	ajaxResult.setSuccess(false);
	
	try {
		
		String id = request.getParameter("id");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String realName = request.getParameter("realName");
		String mobile = request.getParameter("mobile");
		String[] roleIds = request.getParameterValues("roleId");
		
		
		User user = null;
		if(StringUtils.isNotBlank(id)){
			user = userService.find(id);
		}else{
			user = new User();
			user.setUsername(StringUtils.trim(username));
			user.setStatus(User.STATUS_YES);
		}
		
		if(StringUtils.isNotBlank(password)){
			user.setPassword(Md5Util.generatePassword(password));
		}
		
		user.setRealName(StringUtils.trim(realName));
		user.setMobile(StringUtils.trim(mobile));
		
		Set<Role> set = new HashSet<Role>();
		if(roleIds != null){
			for(String roleId : roleIds){
				Role role = roleService.find(roleId);
				if(role != null){
					set.add(role);
				}
			}
		}
		user.setRoles(set);
		
		if(StringUtils.isNotBlank(id)){
			userService.update(user);
		}else{
			user.setType(0);
			userService.save(user);
		}
		ajaxResult.setSuccess(true);
		
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	return ajaxResult;
}
 
Example 20
Project: apache-tomcat-7.0.73-with-comment   File: RestCsrfPreventionFilter.java   View Source Code Vote up 4 votes
protected String[] extractNonceFromRequestParams(
        HttpServletRequest request, String key) {
    return request.getParameterValues(key);
}