I’m upgrading a legacy Java Spring MVC application.
Current setup:
- Java 1.8 (recently upgraded from Java 1.7)
- Spring 3.2.18
- Uses the old
AbstractFormController,SimpleFormController, and XML-based config.
Goal: Upgrade to at least Java 10, preferably Java 17/18, and a newer Spring version (5.x or 6.x).
Problem: In newer Spring versions,
AbstractFormControllerand other form controllers are removed or deprecated. Everything is now annotation-based (@Controller,@RequestMapping, etc.). For example, I currently have something like this:
public class BulkRequestController extends SimpleFormController {
public ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command,BindException errors) throws Exception {
ModelAndView mav = new ModelAndView();
String operation = request.getParameter("hdnOperation");
String mode = request.getParameter("mode");
// My Code
return mav;
}
protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {
final ModelAndView mav = new ModelAndView();
String mid = request.getParameter("mid");
if(CoreUtility.BULK_REQ_STRIKE.equalsIgnoreCase(mid)) {
mav.addAllObjects(setDateValues());
mav.setViewName(getBatchStrikeFormView());
} else {
throw new Exception("Un-implemented mid :" + mid);
}
return mav;
}
}
But in the newer Spring MVC, this whole controller pattern doesn’t exist anymore.
Question:
- What’s the correct way to migrate such controllers to annotation-based Spring MVC (
@Controller,@PostMapping, etc.)? - Are there tools or a standard migration guide for moving from Spring 3.2.x FormControllers to Spring 5/6 annotations?
- Any recommended step-by-step upgrade path (Spring 3 → 4 → 5 → 6) when also upgrading Java (to 10/17)?
- What’s the correct way to migrate such controllers to annotation-based Spring MVC (
Extra Notes:
- The project is large, with many XML-based Spring beans and FormControllers.
- I don’t want to rewrite everything at once; gradual migration advice is appreciated.
@Controllerand annotate the methods with@GetMapping/@PostMappingdepending on which method and use.@GetMappingto yourshowForm()method and@PostMappingtoprocessFormSubmission(). You'll be able to make a lot of simplifications with other annotations as well now, but that should get you started.