spring mvc 中 controller 路径配置

下图中,由于红色部分(value="/")的存在,导致 host:port/项目/dimlist 无法被映射到dimList方法,解决办法是将其去掉。

package cn.bgodata.x.zero.web.ctrl;

import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*; @Component
@RequestMapping("/dimlist")
public class ZeroBiController { @RequestMapping(value="/", method=RequestMethod.GET)
public String dimList(Model model) { return "dimlist";
} @RequestMapping(value="/{randomcode}/nani", method=RequestMethod.POST)
public String dimList(Model model, String randomcode) {
System.out.println("randomcode = " + randomcode);
return "nani";
}
}
上一篇:Spring MVC中返回JSON数据的几种方式


下一篇:Spring MVC中基于注解的 Controller