在json响应内部放置一些变量

发布于 2025-01-18 01:24:39 字数 76 浏览 2 评论 0原文

我们想在 json 响应中添加一些变量,但在方面内。

我们需要做一些类似于此函数中所做的事情,但不是使用请求,而是使用响应。

We want to add some variabale in json response, but inside aspect.

we need to do something similar to what is done in this function but instead of with the request it would be with the response.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我恋#小黄人 2025-01-25 01:24:39

您想要确切的stramp还是只是方向?如果方向,请用自定义注释来注释您的方法以摆脱模式并执行类似的操作:

@Around("@annotation(FQAnnotationName)")
public Map<String, Object> aroundSomething(ProceedingJointPoint jointPoint){
   Map<String, Object> resultOfMethodExecution = (Map<String, Object>) jointPoint.proceed();  
   //do something with the result returned
   return resultOfMethodExecution;
}

此处@around用于在您的方面包装调用。打字目标方法的结果,以您想要的方式对其进行修改。

这只是一个近似的解决方案,不要将其判断为所需内容的确切实现。

you want exact impl or just the direction? if the direction, then annotate your method with custom annotation to get rid of patterns and do something like this:

@Around("@annotation(FQAnnotationName)")
public Map<String, Object> aroundSomething(ProceedingJointPoint jointPoint){
   Map<String, Object> resultOfMethodExecution = (Map<String, Object>) jointPoint.proceed();  
   //do something with the result returned
   return resultOfMethodExecution;
}

Here @Around is used to wrap invocation within your aspect. Typecast the result of target method, modify it in the way you want and return.

This is just an approximated solution, do not judge it as an exact implementation of what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文