I wrote a Spring MVC 3.1.1 controller to do stuff then return showing "Done".
My controller:
@Controller
public class HomeController {
@RequestMapping(value = {"/"}, method = RequestMethod.GET)
public String home(Model model) {
return "home";
}
@RequestMapping(value = {"/dostuff"}, method = RequestMethod.GET)
public String doStuff(ModelMap model) {
doStuff();
model.addAttribute("message", "Done");
return "redirect:/";
}
}
My home.jsp
:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html><body>
${message}
</body></html>
PROBLEM: When I load http://localhost/myapp/dostuff
the page does not show "Done", it is just empty. Also, the URL becomes http://localhost/myapp/?message=Done
instead of going back to a clean http://localhost/myapp/
. What did I do wrong?