简体   繁体   中英

arbitrary parameters in a Spring-boot request

Apologies up front. This should be a 100% google-able question, but I seem to be using the wrong vocabulary.

On an http query, parameters are passed as part of the url string:

curl http://my.host.com/controllerName/actionName?a=b&c=d&e=f&param1=apple&param2=oran

The application specifies a few parameters, and those could be optional:

public HttpEntity<MyResults> actionName(
        @RequestParam(value = "param1", required = true, defaultValue = "Electric Bulb") String param1,
        @RequestParam(value = "param2", required = false ) String param2
        ) throws SomeException { etc}

What I want is if the user passes in some set of params other than what was specified , to capture that in one or more strings to pass downstream. For example, in some languages the 'leftover' query parameters would be a map {param, value}.

Is this possible in Java's type system? If so, how? And what is the right name for them?

当然:传递HttpServletRequest作为参数,并使用request.getParameterMap()来访问所有参数及其值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM