zjialin / springboot2-activiti7 Goto Github PK
View Code? Open in Web Editor NEWSpringBoot2+Activtiti7 整合
SpringBoot2+Activtiti7 整合
前端点击save或 save and close 按钮,后台报错。
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public void com.zjialin.workflow.activiti.ModelSaveRestResource.saveModel(java.lang.String,org.springframework.util.MultiValueMap<java.lang.String, java.lang.String>)]
我的请求如下:
Request URL: http://192.168.31.10:9090/service/model/25834baa-7a08-11ea-9a35-025041000101/save
Request Method: PUT
Status Code: 400
Remote Address: 192.168.31.161:9090
Referrer Policy: no-referrer-when-downgrade
.....
Connection: keep-alive
Content-Length: 60176
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
示例部分请求
返回的结果如下:
{"timestamp":"2020-04-09T07:33:17.789+0000","status":400,"error":"Bad Request","message":"Required request body is missing: public void com.zjialin.workflow.activiti.ModelSaveRestResource.saveModel(java.lang.String,org.springframework.util.MultiValueMap<java.lang.String, java.lang.String>)","path":"/service/model/25834baa-7a08-11ea-9a35-025041000101/save"}
分析原因是:
由于发送的请求使用的是:
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
而该接口使用的@RequestBody
注解 来接收提交的4个参数,这个注册是作用于请求是按
application/json
方式发送请求的,所在用该注解是无法接收到参数的,所以会报400的错误
正解的修改方式是在com.zjialin.workflow.activiti.ModelSaveRestResource
类中保存接口修改如下
@RequestMapping(value = {"/service/model/{modelId}/save"}, method = {org.springframework.web.bind.annotation.RequestMethod.PUT})
@ResponseStatus(HttpStatus.OK)
public void saveModel(@RequestParam MultiValueMap<String, String> values, @PathVariable String modelId) {
....
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/stencilset.json");
com.zjialin.workflow.activiti.StencilsetRestResource
这个类里面引用stencilset.json
文件路径有误,应修改为
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/stencilset.json");
不然工程启动后,会报空指针的错误;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.