i’m new to codeigniter, i have a problem
Is it possible to have same Url pattern to access 2 different methods on Controller?
the difference is the method to access those methods is either GET or POST just like Spring MVC handles it
@RequestMapping(value = "/persons/add", method = RequestMethod.GET)
public String getAdd(Model model)
@RequestMapping(value = "/persons/add", method = RequestMethod.POST)
public String add(@ModelAttribute("personAttribute") Person person)
what i want is, when i access the url like this http://www.bla.com/controller/AddFunction (this is GET) the method that will be triggered is “add1” method which is will load view form and then i have form that has an “action” to controller/AddFunction, at this time because it is POST it will trigger “add2” method
thanks beforehand
You are not required to pass the name of the REST method in the function call. The controller itself can handle input from a GET, POST, or both.
Example:
For further explanation see CodeIgniter’s Documentation on The Input Class