當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.getParameterMap方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getParameterMap方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getParameterMap方法的具體用法?Java HttpServletRequest.getParameterMap怎麽用?Java HttpServletRequest.getParameterMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getParameterMap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createServiceFrom

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public static OpenIdService createServiceFrom(
        final HttpServletRequest request) {
    final String service = request.getParameter(CONST_PARAM_SERVICE);
    final String openIdIdentity = request.getParameter("openid.identity");
    final String signature = request.getParameter("openid.sig");

    if (openIdIdentity == null || !StringUtils.hasText(service)) {
        return null;
    }

    final String id = cleanupUrl(service);
    final String artifactId = request.getParameter("openid.assoc_handle");
    ParameterList paramList = new ParameterList(request.getParameterMap());

    return new OpenIdService(id, service, artifactId, openIdIdentity,
            signature, paramList);
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:18,代碼來源:OpenIdService.java

示例2: logRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Log request.
 *
 * @param request the request
 * @param the
 */
private void logRequest(final HttpServletRequest request) {
    StringBuilder msg = new StringBuilder();
    msg.append(REQUEST_PREFIX).append("\n\tid: '").append(request.getAttribute("Id"))
            .append("', ").append("\n\tcontent type: '").append(request.getContentType())
            .append("', ").append("\n\turl: '").append(request.getRequestURL());
    if (request.getQueryString() != null) {
        msg.append('?').append(request.getQueryString());
    }

    Map<String, String[]> parameters = request.getParameterMap();

    parameters.keySet().forEach((key) -> {
        msg.append("', \n\tparams: '").append(key + " : " + parameters.get(key));
    });

    _log.info("[logRequest] Request: " + msg.toString());
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:24,代碼來源:LoggingFilter.java

示例3: doGet

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    Map map = req.getParameterMap();

    boolean insertWorks;
    try {
        map.put("test", new Integer[] { Integer.valueOf(0) });
        insertWorks = true;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        insertWorks = false;
    }

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    PrintWriter pw = resp.getWriter();
    if (insertWorks) {
        pw.print("FAIL");
    } else {
        pw.print("OK");
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:25,代碼來源:TestApplicationHttpRequest.java

示例4: toMap

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 將異步通知的參數轉化為Map
 * 
 * @param request
 * @return
 */
public static Map<String, String> toMap(HttpServletRequest request) {
	Map<String, String> params = new HashMap<String, String>();
	Map<String, String[]> requestParams = request.getParameterMap();
	for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext();) {
		String name = (String) iter.next();
		String[] values = (String[]) requestParams.get(name);
		String valueStr = "";
		for (int i = 0; i < values.length; i++) {
			valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
		}
		// 亂碼解決,這段代碼在出現亂碼時使用。
		// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
		params.put(name, valueStr);
	}
	return params;
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:23,代碼來源:AliPay.java

示例5: parametersFromHttpServletRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public static Properties parametersFromHttpServletRequest(final HttpServletRequest httpServletRequest) {

    final Properties result = new Properties();
    final Map parameterMap = httpServletRequest.getParameterMap();
    if (parameterMap == null) {
      return result;
    }
    for (final Iterator i = parameterMap.entrySet().iterator(); i.hasNext(); ) {
      final Map.Entry entry = (Map.Entry) i.next();
      final String paramName = (String) entry.getKey();
      if (paramName.startsWith("vti") || paramName.startsWith("cid")) {
        continue;
      }// skip internal viewtier parameters
      final String[] paramValues = (String[]) entry.getValue();
      if (paramValues == null || paramValues.length == 0) {
        continue;
      }
      result.setProperty(paramName, paramValues[0]);
    }
    return result;
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:WebuiUtils.java

示例6: getAssociationResponse

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Gets the association response. Determines the mode first.
 * If mode is set to associate, will set the response. Then
 * builds the response parameters next and returns.
 *
 * @param request the request
 * @return the association response
 */
public Map<String, String> getAssociationResponse(final HttpServletRequest request) {
    final ParameterList parameters = new ParameterList(request.getParameterMap());

    final String mode = parameters.hasParameter(OpenIdProtocolConstants.OPENID_MODE)
            ? parameters.getParameterValue(OpenIdProtocolConstants.OPENID_MODE)
            : null;

    Message response = null;

    if (StringUtils.equals(mode, OpenIdProtocolConstants.ASSOCIATE)) {
        response = this.serverManager.associationResponse(parameters);
    }
    final Map<String, String> responseParams = new HashMap<>();
    if (response != null) {
        responseParams.putAll(response.getParameterMap());
    }

    return responseParams;

}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:29,代碼來源:SmartOpenIdController.java

示例7: getAlipayNotify

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 獲取阿裏支付鏈接的所有參數列表
 *
 * @param request
 * @return
 */
public static Map<String, String> getAlipayNotify(HttpServletRequest request) {
    Map<String, String> params = Maps.newHashMap();
    Map requestParams = request.getParameterMap();
    for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
        String name = iter.next();
        String[] values = (String[]) requestParams.get(name);
        String valueStr = "";
        for (int i = 0; i < values.length; i++) {
            valueStr = (i == values.length - 1) ? valueStr + values[i]
                    : valueStr + values[i] + ",";
        }
        //亂碼解決,這段代碼在出現亂碼時使用。如果mysign和sign不相等也可以使用這段代碼轉化
        //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
        params.put(name, valueStr);
    }
    return params;
}
 
開發者ID:fanqinghui,項目名稱:wish-pay,代碼行數:24,代碼來源:AliPayUtil.java

示例8: getParameterWithOutCode

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 移除url中的code、username參數
 * @param request
 * @return
 */
public static String getParameterWithOutCode(HttpServletRequest request) {
    StringBuffer backUrl = request.getRequestURL();
    String params = "";
    Map<String, String[]> parameterMap = request.getParameterMap();
    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
        if (!entry.getKey().equals("upms_code") && !entry.getKey().equals("upms_username")) {
            if (params.equals("")) {
                params = entry.getKey() + "=" + entry.getValue()[0];
            } else {
                params += "&" + entry.getKey() + "=" + entry.getValue()[0];
            }
        }
    }
    if (!StringUtils.isBlank(params)) {
        backUrl = backUrl.append("?").append(params);
    }
    return backUrl.toString();
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:24,代碼來源:RequestParameterUtil.java

示例9: post

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
public String post(final HttpServletRequest req, final HttpServletResponse res) {
	try {
		final String payload = req.getParameter("payload");
		final JsonParser jsonParser = new JsonParser();
		final JsonObject json = jsonParser.parse(payload).getAsJsonObject();

		final Map<String, String[]> params = req.getParameterMap();

		slackReceiveHandler.handleAction(json, params);
	} catch (final Exception e) {
		handleException(e);
	}

	return "";
}
 
開發者ID:nitroventures,項目名稱:bot4j,代碼行數:17,代碼來源:SlackActionWebhookImpl.java

示例10: switchDomain

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void switchDomain(HttpServletRequest req, HttpServletResponse resp, UsersService as)
    throws ServiceException, ObjectNotFoundException, IOException {
  xLogger.fine("Entered switchDomain");

  // Get the session
  HttpSession session = req.getSession();
  Map<String, String[]> domainDetails = req.getParameterMap();

  // Get the user Id and new domain ID to switch to
  String userId = null;
  Long domainId = null;
  if (domainDetails.containsKey(USERID)) {
    userId = domainDetails.get(USERID)[0];
    if (userId.equalsIgnoreCase("")) {
      writeToScreenWithMode(req, resp,
          "Sorry, could not switch domain since user ID is not specified.", Constants.MODE_MANAGE,
          Constants.VIEW_DOMAINS);
      return;
    }
  }
  if (domainDetails.containsKey(DOMAINID)) {
    String domainIdStr = domainDetails.get(DOMAINID)[0];
    if (domainIdStr.equalsIgnoreCase("")) {
      writeToScreenWithMode(req, resp,
          "Sorry, could not switch domains since domain ID is not specified.",
          Constants.MODE_MANAGE, Constants.VIEW_DOMAINS);
      return;
    }
    domainId = Long.valueOf(domainIdStr);
  }
  // Set the new domain in the session
  SessionMgr.setCurrentDomain(session, domainId);
  // Redirect to the home page
  resp.sendRedirect("/s/index.jsp");
  xLogger.fine("Exiting switchDomain");
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:38,代碼來源:CreateEntityServlet.java

示例11: logRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public void logRequest(HttpServletRequest request)
{
	final StringBuilder params = new StringBuilder(request.getRequestURI() + "\n");
	final Map<String, String[]> parameterMap = request.getParameterMap();
	for( Entry<String, String[]> entry : parameterMap.entrySet() )
	{
		final String key = entry.getKey();
		final String keyLower = key.toLowerCase();
		final boolean blankOut = keyLower.contains("password") || keyLower.contains("secret");
		params.append(key);
		params.append("=");

		boolean firstVal = true;
		final String[] values = entry.getValue();
		if( values != null )
		{
			for( String value : values )
			{
				if( !firstVal )
				{
					params.append(",");
				}
				if( blankOut )
				{
					params.append(Strings.padStart("", value.length(), '*'));
				}
				else
				{
					params.append(value);
				}
				firstVal = false;
			}
		}
		params.append("\n");
	}
	REQUEST_LOGGER.trace(params.toString());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:38,代碼來源:LoggingContextFilter.java

示例12: searchMessage

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Allow conversation-independent search.
 * @param clientName the client id
 * @param request the request to get the query params
 */
@ApiOperation(value = "search for messages", response = SearchResult.class,
        notes = "like solr.")
@RequestMapping(value = "{clientId}/search-message", method = RequestMethod.GET)
public ResponseEntity<?> searchMessage(
        AuthContext authContext,
        @PathVariable(value = "clientId") String clientName,
        HttpServletRequest request
) {
    if (log.isTraceEnabled()) {
        log.debug("{}[{}]: message-search for '{}'", clientName, authContext, request.getParameter("q"));
    } else {
        log.debug("{}: message-search for '{}'", clientName, request.getParameter("q"));
    }

    final Client client = clientService.getByName(clientName);
    if (client == null || !authenticationService.hasAccessToClient(authContext, client.getId())) {
        return ResponseEntity.notFound().build();
    }

    final Map<String, String[]> requestParameterMap = request.getParameterMap();
    if (conversationSearchService != null) {
        try {
            return ResponseEntity.ok(messageSearchService.search(client, requestParameterMap));
        } catch (IOException e) {
            return ResponseEntities.internalServerError(e);
        }
    }

    return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).build();
}
 
開發者ID:redlink-gmbh,項目名稱:smarti,代碼行數:36,代碼來源:RocketChatEndpoint.java

示例13: preHandle

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (LOGGER.isDebugEnabled()) {
        startTime = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();

        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        String methodName = method.getName();
        sb.append(ENTER).append(methodName);

        //參數非空則打印參數
        Map<String, String[]> requestMap = request.getParameterMap();
        if (requestMap != null && !requestMap.isEmpty()) {
            sb.append("(");
            for (Map.Entry<String, String[]> entry : requestMap.entrySet()) {
                sb.append("[");
                sb.append(entry.getKey());
                sb.append("=");
                String[] valueArr = entry.getValue();
                sb.append(valueArr[0].toString());
                sb.append("]");
            }
            sb.append(")");
        }

        LOGGER.debug(sb.toString());
    }

    return true;
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:32,代碼來源:LogInterceptor.java

示例14: getValues

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private Map getValues(HttpServletRequest request){

        Map<String,Object> finalValues = new HashMap<String, Object>();
        Map<String,String[]> map =  request.getParameterMap();

        for(String key : map.keySet()){
            String[] values = map.get(key);
            if(values.length==1)
                finalValues.put(key,values[0]);
            else finalValues.put(key,values);
        }

        return finalValues;

    }
 
開發者ID:Emerjoin,項目名稱:Hi-Framework,代碼行數:16,代碼來源:MVCReqHandler.java

示例15: verifyAliPayRight

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * 支付寶回調接口
 * @param request
 * @param resp
 * @return
 */
@ResponseBody
@RequestMapping(value="/verifyalipayresult.do", method=RequestMethod.POST)
public String verifyAliPayRight(HttpServletRequest request, HttpServletResponse resp)
{
    synchronized (alilock) {
        Map<String,String> params = new HashMap<String,String>();
        Map requestParams = request.getParameterMap();
        for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String[] values = (String[]) requestParams.get(name);
            String valueStr = "";
            for (int i = 0; i < values.length; i++) {
                valueStr = (i == values.length - 1) ? valueStr + values[i]
                        : valueStr + values[i] + ",";
            }
            params.put(name, valueStr);
        }
        try {
            boolean flag = AlipaySignature.rsaCheckV1(params, PayService.ALI_PUBLIC_KEY, "utf-8", "RSA2");
            if(flag)
            {
                if(params.get("trade_status").equals("TRADE_SUCCESS") && params.get("app_id").equals(PayService.ALI_APPID) && params.get("seller_id").equals("2088621136650617"))
                {
                    return payService.verifyAliPay(params);
                }
            }
        } catch (AlipayApiException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "fail";
        }
    }
    return "fail";
}
 
開發者ID:wanliyang1990,項目名稱:AppServiceRestFul,代碼行數:41,代碼來源:PayAction.java


注:本文中的javax.servlet.http.HttpServletRequest.getParameterMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。