You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/05/13 09:20:56 UTC

[GitHub] [servicecomb-java-chassis] kaister3 commented on issue #2373: 通过@ModelAttribute注解传递文件聚合对象时,参数拼接在URI中导致header过长

kaister3 commented on issue #2373:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2373#issuecomment-840433955


   我的写法:
   - 参数类:
   ```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
   ![image](https://user-images.githubusercontent.com/22323152/118105863-868f9d00-b40f-11eb-823b-16b46eb74fd0.png)
   


-- 
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:
users@infra.apache.org