0
0

HttpServletRequestのヘッダをMapに変換

Posted at
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap
import java.util.Map;
import java.util.stream.Collectors;

public class Utils {

    public static Map<String, String> getHeaderMap(HttpServletRequest request) {

        return  new HashMap<String, String>() {{
            Collections.list(request.getHeaderNames())
            	.stream()
                .forEach(key -> {
                	put(key, request.getHeader(key));
            });
    	}};
    }

}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0