@RequestParam Example in Spring

In this tutorial, We will show about, @RequestParam Example in Spring MVC Framework.

Welcome.java

package com.dineshkrish.spring;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class Welcome {
@RequestMapping(value = "sayHello")
public String sayHello(@RequestParam("name") String name) {
return "Hello "+name;
}
@RequestMapping(value = "sayBye")
public String sayBye(@RequestParam("name") String name) {
return "Good bye "+name;
}
@RequestMapping(value = "authenticate")
public boolean authenticate(@RequestParam("userName") String userName, @RequestParam("password") String password) {
if(userName.equals(password)) {
return true;
}
return false;
}
}

References

1. Spring Web Annotation API JavaDocs
2. @RequestParam JavaDocs

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *