title: How to validate request parameter key in springs
body: <p>I am new to spring. Just want to know can we validate request parameters key.
  I have used <code>RequestParam</code> as u can see, for eg  <code>@RequestParam(value= "sourceType")</code> here <code>value = "sourceType"</code> is my key, so if user enters <code>sourcety</code> which does not match the given key it gives <code>400</code> error with sourceType missing in url. Rather then giving <code>404</code> error, I want it only give sourceType missing in url or invalid sourceType? 
  Here is my controller,</p>
  
  <pre><code>@Scope("request")
  @RestController
  public class GetOperatorSeries{
  @RequestMapping(value = "test", method = RequestMethod.GET)
      public String getOperatorSeries(HttpServletResponse response, @RequestParam(value = "mobno") long mobno,
              @RequestParam(value = "sourceType") String sourceType,
              @RequestParam(value = "responseType") String responseType)
  {
  
  }
  </code></pre>
  
  <p>Here is my <code>web.xml</code> file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
      xmlns:web1="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="voiceBank" version="2.5"&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;60&lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;testmemspring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;testmemspring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              /WEB-INF/testmemspring-servlet.xml
             &lt;/param-value&gt;
      &lt;/context-param&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my spring configuration file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:security="http://www.springframework.org/schema/security"
      xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;context:component-scan base-package="com.one97.org" /&gt;
      &lt;context:annotation-config /&gt;
      &lt;mvc:annotation-driven /&gt;
  
      &lt;bean id="testSpring" class="com.one97.org.controller.TestSpring"
          scope="request"&gt;
      &lt;/bean&gt;
  
  
  
      &lt;bean id="internalViewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
          &lt;property name="order" value="1" /&gt;
      &lt;/bean&gt;
  
  
  
  
  &lt;/beans&gt;
  </code></pre>