基本配置:
web.xmlspringMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath*:config/spring-servlet.xml 1 springMVC /
spring-servlet.xml
controller
import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.multiaction.MultiActionController;//继续MultiActionController来实现根据参数名指定要请求的方法public class MultiController extends MultiActionController { public ModelAndView add(HttpServletRequest request,HttpServletResponse response){ return new ModelAndView("/welcome","methodName","add"); } public ModelAndView delete(HttpServletRequest request,HttpServletResponse response){ return new ModelAndView("/welcome","methodName","delete"); }}
jsp
${methodName}
结果: