gpt4 book ai didi

java - 如何更改 Spring & Jhipster 身份验证不足错误消息

转载 作者:行者123 更新时间:2023-12-02 11:08:19 25 4
gpt4 key购买 nike

我正在尝试更改每当用户尝试向后端发送请求并且其 token 已过期时显示的默认消息。默认消息是:

translation-not-found[Unauthorized: Full authentication is required to access this resource]

作为 InsufficientAuthenticationException 的结果。

我想将其更改为用户可以理解的内容。也许:

Your session has expired, please log in again!

我尝试过:

  • 我在后端搜索InsufficientAuthenticationException,但没有找到引用。
  • 我使用过期 token 调试 post 请求,但它从未进入断点。

这是发布请求代码:

@PostMapping("/images")
@Timed
public ResponseEntity<Image> createImage(@Valid @RequestBody Image image) throws URISyntaxException {
log.debug("REST request to save Imagen : {}", imagen);
if (imagen.getId() != null) {
throw new BadRequestAlertException("A new image cannot already have an ID", ENTITY_NAME, "idexists");
}
Image result = fileServerService.saveImage(image);
result = imagenRepository.save(result);
return ResponseEntity.created(new URI("/api/images/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}

但我认为这与这部分代码无关,因为它永远不会进入刹车点。

我的问题是:

  • 此错误消息位于何处?
  • 我可以在前端的翻译文件中更改它吗?

感谢您的宝贵时间!祝你有美好的一天。

最佳答案

我已经通过在 global.json 文件中添加翻译来解决这个问题,我只是在“global”的同一级别添加了这一行:{}:

"Unauthorized: Full authentication is required to access this resource": "The translation that i want",
"global": {
...global stuff..
}

关于java - 如何更改 Spring & Jhipster 身份验证不足错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50764474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com