java自定义404返回,因为spring 包装的没有code,所以需要自定义返回,spring会在404自动重定向ip:porterror的url

    技术2022-07-13  90

    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; } }
    Processed: 0.015, SQL: 9