SenixCoder commented on issue #2373:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2373#issuecomment-840436798
> 我的写法:
>
> * 参数类:
>
> ```java
> public class Person {
> private int age;
>
> private String name;
>
> public int getAge() {
> return age;
> }
>
> @FormParam("age")
> public void setAge(int age) {
> this.age = age;
> }
>
> public String getName() {
> return name;
> }
>
> @FormParam("name")
> public void setName(String name) {
> this.name = name;
> }
> }
> ```
>
> * provider方的controller
>
> ```java
> @RestSchema(schemaId = "helloService")
> @Path("/hello")
> public class HelloService {
>
> @Path("/sayHello")
> @POST
> public String sayHello(@BeanParam Person person) {
> System.out.println("sayHello is called, and person is [" + person
+"]");
> return "Hello, your name is " + person.getName() + ", and age is "
+ person.getAge();
> }
> }
> ```
>
> * consumer方的controller
>
> ```java
> @RpcSchema(schemaId = "helloController")
> public class HelloController {
> @RpcReference(microserviceName = "2373-server", schemaId =
"helloService")
> private HelloServiceIntf hello;
>
> @Path("/test")
> @GET
> public String Hello() {
> return hello.sayHello("asd", 12);
> }
> }
> ```
>
> * consumer 方rpc接口
>
> ```java
> package org.servicecomb.sample;public interface HelloServiceIntf {
> String sayHello(String name, int age);
> }
> ```
>
> 最终实现的效果是参数被写进body
>

需要携带Part对象,不同的Bean是可以写进body的
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]