当我调用RequestMapped类(不是方法)时执行什么代码?

时间:2017-09-07 09:52:14

标签: java spring

我调用了一个用RequestMapping定义的类,但我不知道在类上执行了什么代码。

class MockActivatedRoute {
  // here you can add your mock objects, like snapshot or parent or whatever
  // example:
  parent = {
    snapshot: {data: {title: 'myTitle ' } },
    routeConfig: { children: { filter: () => {} } }
  };
}

我上了这堂课:

<form th:action="@{/admin/gestionUtilisateurs.action}" method="post">
    <label>Numéro de contrat: </label>
    <input type="text" id="numeroContrat" name="numeroContrat" />
    <input type="submit" id="changerInformations" name="changerInformations" value="Charger les informations" class="w_actionButton"/>
</form>

所以,我想知道执行什么代码以及为什么。

1 个答案:

答案 0 :(得分:1)

鉴于代码:

<form th:action="@{/admin/gestionUtilisateurs}" method="post">
    <label>Numéro de contrat: </label>
    <input type="text" id="numeroContrat" name="numeroContrat" />
    <input type="submit" id="changerInformations" name="changerInformations" value="Charger les informations" class="w_actionButton"/>
</form>

将执行方法getInformationContrat:

@RequestMapping(method = RequestMethod.POST, params = { "changerInformations" }, produces = MediaType.APPLICATION_JSON_VALUE)
public String getInformationContrat(HttpServletRequest request, InformationContratForm informationContrat, BindingResult result, Model model) {
    //code
}

因为输入的属性名称是 changerInformations ,所以它将与@RequestMapping注释的属性参数绑定。

相关问题