我想了解我的項目代碼,同時學習Spring MVC。Spring MVC中沒有參數的@RequestMapping
在春季@RequestMapping
註釋需要參數。例如,
@RequestMapping(value="/something", method=RequestMethod.POST)
@RequestMapping(value="/index.html", method=RequestMethod.GET)
@RequestMapping("/index")
@RequestMapping(params="command=GETINFO")
我的項目使用註釋,它不使用任何XML進行映射。我有一個以下的控制器結構。
@Controller
public class RuleStepController {
private static final String ATTRIBUTE_BRANCH = "branch";
private static final String ATTRIBUTE_EDIT_FORM = "editForm";
.................
@Autowired
private RuleStepService ruleStepService;
@Autowired
private PopulationDao populationDao;
@RequestMapping
public void ruleStepEntForm(Long populationId, ModelMap model) {
.....
editForm.setStepEnt(stepDto);
}
@RequestMapping
public void ruleStepOrgCount(RuleStepOrgSearchForm searchForm, ModelMap model){
.......
model.addAttribute("searchForm", searchForm);
}
@RequestMapping
public String ruleStepMgrForm() {
logger.debug(String.format("ruleStepMgrForm"));
return "forward:/employee/employeeSearchForm.view?relationshipId=0&roleId=0&formId=stepMgr";
}
我想明白會是什麼@RequestMapping
意義當它不帶任何參數?
@AutoWired
有什麼用?
不帶任何參數是在一個方法中使用,則它使用從GET/POST請求中識別輸入參數的方法的參數。例如。在你的'ruleStepEntForm'方法中,GET/POST中的參數應該被命名爲'populationId' – Pat