Java Code Examples for org.springframework.web.bind.MissingServletRequestParameterException

Following code examples demonstrate how to use org.springframework.web.bind.MissingServletRequestParameterExceptionfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.bind.MissingServletRequestParameterExceptionand various code implementation of this class.

  public GrootError giveError(MissingServletRequestParameterException exception) {
    GrootError error = new GrootError();
    if (exception.getParameterName().equals("message")) {
      error.setError("I am Groot!");
    }
    return error;
  } 


    public String requestMissingServletRequest(MissingServletRequestParameterException ex){
        ex.printStackTrace();
        return ex.getParameterName()+" is empty";
    } 

    public SimpleException handleMissingParameterException(MissingServletRequestParameterException e){

        return new SimpleException(ResultEnums.PARAMETER_INVALID,e.getMessage());
    } 

    
    protected Map<String, Object> parseAttributes(final String attributes) throws

        MissingServletRequestParameterException {
        ObjectMapper mapper = new ObjectMapper();


        try {
            JsonParser jp = factory.createParser(attributes);
            return mapper.readValue(jp, HashMap.class);
        } catch (IOException e) {
            throw new MissingServletRequestParameterException("attributes", "Json");
        }
    } 

    {
        if(t instanceof MissingServletRequestParameterException)
        {
            MissingServletRequestParameterException me = (MissingServletRequestParameterException)t;
            String parameterName = me.getParameterName();
        }
    } 

Advertisement
Javadoc
ServletRequestBindingException subclass that indicates a missing parameter. @author Juergen Hoeller

@since 2.0.2

Read More
Advertisement