Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.4.0版本执行器注册调度中心400问题 #3433

Open
chenaojie opened this issue Apr 23, 2024 · 0 comments
Open

2.4.0版本执行器注册调度中心400问题 #3433

chenaojie opened this issue Apr 23, 2024 · 0 comments

Comments

@chenaojie
Copy link

因为core的XxlJobRemotingUtil.postBody方法里使用了
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");

而JobApiController 用的以下接收,data是接收不到数据的因为还有个uri的参数
@RequestMapping("/{uri}")
@responsebody
@PermissionLimit(limit=false)
public ReturnT api(HttpServletRequest request, @PathVariable("uri") String uri, @requestbody(required = false) String data)

XxlJobRemotingUtil.postBody 我这边改成了
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
connection.setRequestProperty("Accept-Charset", "application/x-www-form-urlencoded;charset=UTF-8");

请求的参数encode一下
String requestBody = URLEncoder.encode(GsonTool.toJson(requestObj), "UTF-8");

JobApiController接收时decode一下
data = URLDecoder.decode(data, Charset.forName("UTF-8"));
这样是可以注册的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant