/** * Get a long parameter, with a fallback value. Never throws an exception. * Can pass a distinguished value as default to enable checks of whether it was supplied. * @param request current HTTP request * @param name the name of the parameter * @param defaultVal the default value to use as fallback */ public static long getLongParameter(ServletRequest request, String name, long defaultVal) { if (request.getParameter(name) == null) { return defaultVal; } try { return getRequiredLongParameter(request, name); } catch (ServletRequestBindingException ex) { return defaultVal; } }
/** * Get a Long parameter, or {@code null} if not present. * Throws an exception if it the parameter value isn't a number. * @param request current HTTP request * @param name the name of the parameter * @return the Long value, or {@code null} if not present * @throws ServletRequestBindingException a subclass of ServletException, * so it doesn't need to be caught */ @Nullable public static Long getLongParameter(ServletRequest request, String name) throws ServletRequestBindingException { if (request.getParameter(name) == null) { return null; } return getRequiredLongParameter(request, name); }
/** * Get a long parameter, with a fallback value. Never throws an exception. * Can pass a distinguished value as default to enable checks of whether it was supplied. * @param request current HTTP request * @param name the name of the parameter * @param defaultVal the default value to use as fallback */ public static long getLongParameter(ServletRequest request, String name, long defaultVal) { if (request.getParameter(name) == null) { return defaultVal; } try { return getRequiredLongParameter(request, name); } catch (ServletRequestBindingException ex) { return defaultVal; } }
/** * Get a Long parameter, or {@code null} if not present. * Throws an exception if it the parameter value isn't a number. * @param request current HTTP request * @param name the name of the parameter * @return the Long value, or {@code null} if not present * @throws ServletRequestBindingException a subclass of ServletException, * so it doesn't need to be caught */ @Nullable public static Long getLongParameter(ServletRequest request, String name) throws ServletRequestBindingException { if (request.getParameter(name) == null) { return null; } return getRequiredLongParameter(request, name); }
ServletRequestUtils.getRequiredLongParameter(request, "param2"); fail("Should have thrown ServletRequestBindingException"); assertEquals(ServletRequestUtils.getLongParameter(request, "param3", 6L), 6L); try { ServletRequestUtils.getRequiredLongParameter(request, "param3"); fail("Should have thrown ServletRequestBindingException"); ServletRequestUtils.getRequiredLongParameter(request, "paramEmpty"); fail("Should have thrown ServletRequestBindingException");
/** * Get a long parameter, throwing an exception if it isn't found or isn't a number. * @param request current HTTP request * @param name the name of the parameter * @throws ServletRequestBindingException a subclass of ServletException, * so it doesn't need to be caught */ public static long getRequiredLongParameter(ServletRequest request, String name) throws ServletRequestBindingException { return org.springframework.web.bind.ServletRequestUtils.getRequiredLongParameter(request, name); }
/** * Get a long parameter, with a fallback value. Never throws an exception. * Can pass a distinguished value as default to enable checks of whether it was supplied. * @param request current HTTP request * @param name the name of the parameter * @param defaultVal the default value to use as fallback */ public static long getLongParameter(ServletRequest request, String name, long defaultVal) { if (request.getParameter(name) == null) { return defaultVal; } try { return getRequiredLongParameter(request, name); } catch (ServletRequestBindingException ex) { return defaultVal; } }
/** * Get a long parameter, with a fallback value. Never throws an exception. * Can pass a distinguished value as default to enable checks of whether it was supplied. * @param request current HTTP request * @param name the name of the parameter * @param defaultVal the default value to use as fallback */ public static long getLongParameter(ServletRequest request, String name, long defaultVal) { if (request.getParameter(name) == null) { return defaultVal; } try { return getRequiredLongParameter(request, name); } catch (ServletRequestBindingException ex) { return defaultVal; } }
/** * Get a Long parameter, or {@code null} if not present. * Throws an exception if it the parameter value isn't a number. * @param request current HTTP request * @param name the name of the parameter * @return the Long value, or {@code null} if not present * @throws ServletRequestBindingException a subclass of ServletException, * so it doesn't need to be caught */ @Nullable public static Long getLongParameter(ServletRequest request, String name) throws ServletRequestBindingException { if (request.getParameter(name) == null) { return null; } return getRequiredLongParameter(request, name); }
/** * Get a Long parameter, or {@code null} if not present. * Throws an exception if it the parameter value isn't a number. * @param request current HTTP request * @param name the name of the parameter * @return the Long value, or {@code null} if not present * @throws ServletRequestBindingException a subclass of ServletException, * so it doesn't need to be caught */ @Nullable public static Long getLongParameter(ServletRequest request, String name) throws ServletRequestBindingException { if (request.getParameter(name) == null) { return null; } return getRequiredLongParameter(request, name); }