我们已经编写了一个服务控制器,用于在春天提供休息服务,就像---
@Controller
public class ServicesController {
//first service
@ResponseBody
@RequestMapping(value = "/emailDomainValidate", method = RequestMethod.POST, headers = { jsonContentType })
public List<String> emailDomailValidate(@RequestBody EmailDomainValidateVO emailDomainValidate) {
List<String> errorCodes = getEmailDomainValidationService().emailDomainValidation(
emailDomainValidate);
}
//second service
@ResponseBody
@RequestMapping(value = "/changePassword", method = RequestMethod.POST, headers = { jsonContentType })
public List<String> changePassword(@RequestBody ChangePasswordVO changePasswordVO) {
List<String> passwords = getChangePasswordFacade().changePassword(changePasswordVO);
}
}
在web.xml中我们提供了
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
当我们通过休息呼叫访问其中一个服务时---- http://“url”:8080 / service / emailDomainValidate ---这是有效的
但是当我们访问其他服务时 http://“url”:8080 / service / changePassword ---这不起作用,给我们400个http错误代码
到目前为止我们执行的步骤是----
请告诉我为什么当提供的所有其他服务正常工作时,这仍然不起作用
非常感谢
答案 0 :(得分:0)
尝试将映射添加到控制器,然后将映射添加到方法中。这至少对我有用:
@Controller
@RequestMapping('/rest')
public class ServicesController {
private static final Log log = LogFactory.getLog(ExampleRestController.class);
@ResponseBody
@RequestMapping(value = "/emailDomainValidate", method = RequestMethod.POST, headers = { jsonContentType })
public List<String> emailDomailValidate(@RequestBody EmailDomainValidateVO emailDomainValidate) {
if(log.isDebugEnabled()) log.debug('emailDomainValidate hit');
List<String> errorCodes = getEmailDomainValidationService().emailDomainValidation(emailDomainValidate);
}
//second service
@ResponseBody
@RequestMapping(value = "/changePassword", method = RequestMethod.POST, headers = { jsonContentType })
public List<String> changePassword(@RequestBody ChangePasswordVO changePasswordVO) {
if(log.isDebugEnabled()) log.debug('change password hit');
List<String> passwords = getChangePasswordFacade().changePassword(changePasswordVO);
}
}
然后你会发帖到:
http://localhost:8080/service/rest/emailDomainValidate
http://localhost:8080/service/rest/changePassword