2 hocharm hocharm 于 2015.05.27 15:45 提问

域名访问springmvc问题

@Controller
@RequestMapping("/index")
public class IndexRpc extends MultiActionController {

@RequestMapping(value = "toIndex", method = RequestMethod.GET)
  public String projectIndex(Model model, HttpServletRequest request,
          HttpServletResponse response,HttpSession session) {
             return "view/index";
        }

}

这是一个springMVC类和方法,使用域名:http://www.xx.com/index/toIndex 可以访问首页 但如何使用:http://www.xx.com 访问首页呢?谢谢

4个回答

stvnshi
stvnshi   2015.05.27 15:49

@Controller
@RequestMapping("/")
public class IndexRpc extends MultiActionController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String projectIndex(Model model, HttpServletRequest request,
HttpServletResponse response,HttpSession session) {
return "view/index";
}
}

stvnshi
stvnshi   2015.05.27 15:49

@Controller
@RequestMapping("/")
public class IndexRpc extends MultiActionController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String projectIndex(Model model, HttpServletRequest request,
HttpServletResponse response,HttpSession session) {
return "view/index";
}
}

diaoliwei2
diaoliwei2   Rxr 2015.05.27 16:06

将这个页面访问地址放到web.xml中的welcome-file-list欢迎页面中不行吗

yuyang199
yuyang199   2015.05.28 16:25

写一个拦截器,拦截请求并转发到你想要跳转的请求就可以了

Csdn user default icon
上传中...
上传图片
插入图片