本文整理匯總了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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]);
}
}
}
}
示例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);
}
示例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");
}
}
示例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, "");
}
示例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;
}
示例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;
}
示例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;
}
示例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"));
}
示例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;
}
示例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>");
}
}
示例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;
}