Since then I built a nice Framework where developers could just concentrate on implementing Controller logic, reusable services and DAOs.
A new project has come to my plate and a new team eager to use the latest from Spring (Spring 3). I would love to be wrong but Spring3 is favoring the use of annotations for URL/Controller Mapping and my simple GreetingController will not longer work with ControllerClassNameHandlerMapping
So now my Controller will need to repeat himself === not agile (Note I tested this with the Spring3 Petclinic example):
package org.springframework.samples.petclinic.web;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
public class GreetingController {
@RequestMapping("/greeting/hi")
public ModelAndView hi(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
ModelAndView mav = new ModelAndView("messageView");
mav.addObject("message", "Hi");
return mav;
}
@RequestMapping("/greeting/hello")
public ModelAndView hello(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView mav = new ModelAndView("messageView");
mav.addObject("message", "Hello");
return mav;
}
}
IMHO if it says it is a controller and it has public methods that should be enough so it is missing a default (and very useful) implementation. If it walks like a duck it must be then a duck.
2 comments:
But the documentation still brings the CoC as an option, wierd...
http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch16s10.html
I have posted in Spring3 forums the question ( http://forum.springsource.org/showthread.php?p=309114#post309114 )
The suggested CoC from your link is not taking into consideration MultiActioController and in a real CoC approach you should support them as REST is still not preferred by some teams (I include myself there) for a simple reason: Browsers still do not support the 4 verbs and then you need to tweak DELETE/PUT actions.
Post a Comment