GithubHelp home page GithubHelp logo

springboot2-activiti7's Issues

ModelSaveRestResource.saveModel方法调用失败

前端点击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>)]

设计器保存接口报400错误

我的请求如下:

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) {
....

知识点参考:
获取接口请求中的参数(@PathVariable,@RequestParam,@RequestBody)

image

设计器访问会报空指针的错误

com.zjialin.workflow.activiti.StencilsetRestResource这个类里面引用stencilset.json文件路径有误,应修改为

InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/stencilset.json");

不然工程启动后,会报空指针的错误;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.