Java 如何使用可以用不同值填充HttpServletRequest的remoteUser的邮递员来模拟请求?

Java 如何使用可以用不同值填充HttpServletRequest的remoteUser的邮递员来模拟请求?,java,postman,Java,Postman,我现在正在使用POSTMAN测试RESTFul API。API是使用Java和Spring Boot开发的 在REST控制器中,它通过检查远程用户来验证请求,如下所示: boolean validate(HttpServletRequest request) { if (request.getRemoteUser() == "Test123") { return true; } return false; } 那么,如何使用POSTMAN生成请求以填充Ht

我现在正在使用POSTMAN测试RESTFul API。API是使用Java和Spring Boot开发的

在REST控制器中,它通过检查远程用户来验证请求,如下所示:

boolean validate(HttpServletRequest request) {
    if (request.getRemoteUser() == "Test123") {
       return true;
    }
    return false;
}

那么,如何使用POSTMAN生成请求以填充
HttpServletRequest
对象的
remoteUser

您需要在POSTMAN请求中添加基本身份验证头这是否回答了您的问题?我已经将授权设置为“basic auth”,但是HttpServletRequest对象的getRemoteUser()方法仍然返回null。您好@Kelvin您使用的是spring安全还是其他形式的安全实现?如果您使用的是spring security,则可能需要添加自定义筛选器。请参阅[Spring security从httpServletRequest中删除RemoteUser]()