package com.itranswarp.crypto.web.api.v1; import com.itranswarp.crypto.ApiError; import com.itranswarp.crypto.bean.ResponseWrapper; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @Author: wangwu * @Date: Created in 11:00 2020-07-02 * @Description: */ @RestController public class NotPathController { @RequestMapping public Object error(){ ResponseWrapper responseWrapper = new ResponseWrapper(); responseWrapper.setStatus(ResponseWrapper.STATUS_FAIL); responseWrapper.setCode(ApiError.PATH_NOT_FOUND.name()); responseWrapper.setData(""); return responseWrapper; } }
java自定义404返回,因为spring 包装的没有code,所以需要自定义返回,spring会在404自动重定向ip:port/error的url
最新推荐文章于 2021-09-23 17:33:07 发布