dimanche 15 mars 2015

extending spring mvc controller without using adapter pattern

I have one controller which has 4 request mapping and I cannot do changes in this controller. Is it possible to have a class(controller/component) which overrides one of the request mapping methods to have my custom implementation for this request mapping and using the other 3 request mapping methods as is. Is it possible?


Below is a sample code:



@Controller
public class Base {

@RequestMapping("/add")
public String add() throws Exception {
return "add";
}

@RequestMapping("/update")
public String update() throws Exception {
return "update";
}

@RequestMapping("/remove")
public String remove() throws Exception {
return "remove";
}

@RequestMapping("/show")
public String show() throws Exception {
return "show";
}
}


public class ExtendedBase extends Base {
public String add() throws Exception {
return "newAdd";
}
}

Aucun commentaire:

Enregistrer un commentaire