我想设计一个快速注册页面,当我提交该字段时,该页面位于页脚,它显示一些错误“不支持请求方法POST”。有人,请帮助我解决这个错误。
我已将commandName形式的属性修改为modelAttribute,但是仍然存在错误。
@RequestMapping(value = "/setSubscribe", method = RequestMethod.POST) private String doSubscribe(@ModelAttribute("subscribeForm") final SubscribeForm form) { final RegisterData registerData = new RegisterData(); registerData.setFirstName(form.getFirstName()); registerData.setLastName(form.getLastName()); registerData.setSex(form.getGender()); registerData.setLogin(form.getEmail()); final CerCustomerFacadeImpl customerFacadeImpl = new CerCustomerFacadeImpl(); try { customerFacadeImpl.newCerRegister(registerData, true); } catch (final Exception e) { e.printStackTrace(); } return ""; }
{ "multicast_id": 6319718121948146737, "success": 0, "failure": 1, "canonical_ids": 0, "results": [ { "error": "InvalidRegistration" } ] }
它必须按照控制者中提到的业务行事。
答案 0 :(得分:0)
使用@ResponseBody注释编写您的控制器方法,并使用@RequestMapping注释的属性,如下所示:
@RequestMapping(value = "/setSubscribe", method = RequestMethod.POST, consumes = "application/json")
@ResponseBody
private String doSubscribe(@ModelAttribute("subscribeForm") final SubscribeForm form)
{
return "";
}