我正在尝试使用 GET 方法创建一个简单的 Spring 项目,但无法访问它。这是我的控制器...
package controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
public class IndexController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
String message = "Hello, World!";
return new ModelAndView("index", "msg", message);
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView setupForm(@RequestParam("name") String name) {
return new ModelAndView("index", "msg", name);
}
}
例如,当我键入 URL:“http://localhost:8080/HelloWorld/index.htm?name=jon”时,它只返回顶部方法。有任何想法吗?
非常感谢,J