当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletRequest.getParameterValues方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletRequest.getParameterValues方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletRequest.getParameterValues方法的具体用法?Java HttpServletRequest.getParameterValues怎么用?Java HttpServletRequest.getParameterValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getParameterValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureCustomMenus

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
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;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:JSHTMLAction_1_1.java

示例2: unBind

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:25,代码来源:SchoolAccountController.java

示例3: parseParameterNames

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
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;
}
 
开发者ID:CFshuming,项目名称:bfmvc,代码行数:27,代码来源:ParameterUtil.java

示例4: exportExcelSelectedLessons

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
    * 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;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:GradebookMonitoringAction.java

示例5: printParams

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@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]);
        }
      }
    }

}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:30,代码来源:MsTeamsNotificationTestServer.java

示例6: getValue

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:QueryProcessorCreator.java

示例7: doPost

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * @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");
	}
}
 
开发者ID:erikns,项目名称:webpoll,代码行数:40,代码来源:NewMultiplechoiceQuestionServlet.java

示例8: role

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@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, "");
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:10,代码来源:UpmsUserController.java

示例9: ajaxArticleTop

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 文章置顶
 * @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;
}
 
开发者ID:xujeff,项目名称:tianti,代码行数:32,代码来源:CmsController.java

示例10: ajaxUpdColumnDelete

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 栏目删除
 * @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;
}
 
开发者ID:xujeff,项目名称:tianti,代码行数:41,代码来源:CmsController.java

示例11: catalogStrToList

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
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;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:29,代码来源:CatalogConvertorController.java

示例12: doUrlCheck

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 *  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"));
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:49,代码来源:DDSServicesAction.java

示例13: validateRequestArguments

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 *  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;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:40,代码来源:RepositoryAction.java

示例14: mulDel

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 批量删除功能
 * @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>");
    }
}
 
开发者ID:aimkiray,项目名称:sgroup,代码行数:20,代码来源:BootstrapProductServlet.java

示例15: ajaxSaveRole

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * 保存角色
 * @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;
}
 
开发者ID:xujeff,项目名称:tianti,代码行数:53,代码来源:UserController.java


注:本文中的javax.servlet.http.HttpServletRequest.getParameterValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。