content/references/java-chassis/en_US/build-provider/springmvc/index.html (610 lines of code) (raw):
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="../../img/favicon.ico" />
<title>Develop with SpringMVC - ServiceComb Java Chassis Developers Guide</title>
<link rel="stylesheet" href="../../css/theme.css" />
<link rel="stylesheet" href="../../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
<script>
// Current page data
var mkdocs_page_name = "Develop with SpringMVC";
var mkdocs_page_input_path = "build-provider/springmvc.md";
var mkdocs_page_url = null;
</script>
<script src="../../js/jquery-3.6.0.min.js" defer></script>
<!--[if lt IE 9]>
<script src="../../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../.." class="icon icon-home"> ServiceComb Java Chassis Developers Guide
</a><div role="search">
<form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../..">Introduction</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../start/terminology/">Glossary</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../start/architecture/">Architecture</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../start/development-environment/">Development environment</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../start/first-sample/">Develop the first microservice</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Development Service Provider</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../definition/service-definition/">Service definition</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../define-contract/">Service contract definition</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../code-first/">Implicit API definition</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../swagger-annotation/">Use Swagger annotations</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">Develop with SpringMVC</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#concept-description">Concept Description</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#development-example">Development Example</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#step1-define-the-service-interface-optional">Step1 Define the service interface (optional)</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#step2-implement-the-services">Step2 Implement the services</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#step4-wrtie-a-main-class">Step4 Wrtie a main class</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#using-pojo-as-query-parameters">Using POJO as query parameters</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#description">Description</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#examples">Examples</a>
<ul>
<li class="toctree-l4"><a class="reference internal" href="#provider">Provider</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#consumer">Consumer</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#servicecomb-suppoted-spring-mvc-annotations-and-differences">ServiceComb suppoted Spring MVC annotations and differences</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#table-1-1-annotations">Table 1-1 annotations</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../jaxrs/">Develop with JAX-RS</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../transparent-rpc/">Develop with Transparent RPC</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../interface-constraints/">Interface definition and data type</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../listen-address-and-publish-address/">Service listening address and publishing address</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../thread-pool/">Thread pool</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="#">Service Configuration</a>
<ul>
<li class="toctree-l2"><a class="reference internal" href="../configuration/ratelimite-strategy/">Rate Limiting Policy</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="../configuration/downgrade-strategy/">Fallback Policy</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="../configuration/parameter-validator/">Parameter Validator</a>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../bootup/">Boot-up Process</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../access-log-configuration/">Access Log Configuration</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Writing Service Consumer</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/common-configuration/">Consumer common configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/using-resttemplate/">Using Rest Template</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/using-AsyncRestTemplate/">Using AsyncRestTemplate</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/develop-consumer-using-rpc/">Using with RPC</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/with-contract/">Contract</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="#">Invoke control</a>
<ul>
<li class="toctree-l2"><a class="reference internal" href="../../build-consumer/circuit-breaker/">Circuit Breaker</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../build-consumer/flow-control/">Flow Control</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../build-consumer/fault-injection/">Fault Injection</a>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../build-consumer/3rd-party-service-invoke/">Invoke 3rd-party REST services</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Transports</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../transports/rest-over-servlet/">REST over Servlet</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../transports/rest-over-vertx/">REST over Vertx</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../transports/highway-rpc/">Highway</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../transports/http2/">HTTP2</a>
</li>
</ul>
<p class="caption"><span class="caption-text">General Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/visit-sc/">Access Service Center</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/metrics/">Metrics</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/microservice-invocation-chain/">Microservice invocation chain</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/customized-tracing/">Customized-Tracing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/local-develop-test/">Local development and testing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/http-filter/">Http Filter</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/file-upload/">File Uploading</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/file-download/">File Downloading</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/reactive/">Reactive Programing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/dnsconfig/">DNS Custom Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/dai-li-she-zhi/">Proxy Settings</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/report-framework-version/">Report framework version</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/cross-app-invocation/">Cross-application invocation</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/secret-field/">Customized serialization and deserialization</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/context/">Using Context to pass control messages</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/produceprocess/">Return value serialization extension</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/CORS/">CORS mechanism</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/AlarmEvent/">Get fuse and instance isolation alarm event information</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/shutdown/">Shutdown gracefully</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/error-handling/">Handling exceptions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/multienvironment/">Multi-environment isolation between microservice instances</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../general-development/thread-model/">Thread Model</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Configuration</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../config/general-config/">General config</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../config/inject-config/">Configuration injection</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Service Capability Open</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../edge/open-service/">Intruductions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../edge/by-servicecomb-sdk/">Using Edge Service</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../edge/nginx/">Using confd and Nginx as edge services</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../edge/zuul/">Use zuul as edge services</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Service Packing and Running</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../packaging/standalone/">Standalone mode</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../packaging/web-container/">WEB container mode</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Micro Service Security</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../security/tls/">Using TLS</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../security/rsa/">Using RSA certification</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Using java chassis in Spring Boot</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/using-java-chassis-in-spring-boot/">Intruductions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/components-for-spring-boot/">spring boot starter for java-chassis</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/java-application/">JAVA application development</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/web-application/">Web development method development</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/diff-between-java-web/">The difference between JAVA application method and Web development method</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../using-java-chassis-in-spring-boot/diff-spring-mvc/">The difference in Spring MVC mode</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Handlers reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../references-handlers/intruduction/">Intruductions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../references-handlers/loadbalance/">Load Balancing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../references-handlers/publickey/">Public key authentication</a>
</li>
</ul>
<p class="caption"><span class="caption-text">FAQ</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../question-and-answer/question_answer/">Q & A</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../question-and-answer/faq/">FAQ</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../question-and-answer/interface-compatibility/">Micro Service Interface Compatibility FAQ</a>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../..">ServiceComb Java Chassis Developers Guide</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../.." class="icon icon-home" alt="Docs"></a> »</li>
<li>Development Service Provider »</li>
<li>Develop with SpringMVC</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">
<h1 id="develop-microservice-with-springmvc">Develop Microservice with SpringMVC</h1>
<h2 id="concept-description">Concept Description</h2>
<p>ServiceComb supports Spring MVC annotations to define your REST services. The <a href="https://github.com/apache/servicecomb-java-chassis/tree/master/samples/springmvc-sample">samples project</a> has a lot of working examples.</p>
<h2 id="development-example">Development Example</h2>
<h3 id="step1-define-the-service-interface-optional">Step1 Define the service interface (optional)</h3>
<p>Writing a interface for the REST service make it easy to call the service in client in RPC style.</p>
<pre><code class="language-java">public interface Hello {
String sayHi(String name);
String sayHello(Person person);
}
</code></pre>
<h3 id="step2-implement-the-services">Step2 Implement the services</h3>
<p>The annotations of Spring MVC are used to describe the development of service code. The implementation of the Hello service is as follow:</p>
<p>```java
@RestSchema(schemaId = "springmvcHello")
@RequestMapping(path = "/springmvchello", produces = MediaType.APPLICATION_JSON)
public class SpringmvcHelloImpl implements Hello {
@Override
@RequestMapping(path = "/sayhi", method = RequestMethod.POST)
public String sayHi(@RequestParam(name = "name") String name) {
return "Hello " + name;
}</p>
<pre><code>@Override
@RequestMapping(path = "/sayhello", method = RequestMethod.POST)
public String sayHello(@RequestBody Person person) {
return "Hello person " + person.getName();
}
</code></pre>
<p>}</p>
<pre><code>
### Step3 add a component scan (optional)
create `resources/META-INF/spring` folder and add `springmvcprovider.bean.xml`, add component-scan to specify the bean package. This step is optional. The package where main class located is automatically added.
```xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.apache.servicecomb.samples.springmvc.povider"/>
</beans>
</code></pre>
<h3 id="step4-wrtie-a-main-class">Step4 Wrtie a main class</h3>
<p>This code using log4j as the logger framework. Users can change it to any other favorite logger framework.</p>
<pre><code class="language-java">public class SpringmvcProviderMain {
public static void main(String[] args) throws Exception {
Log4jUtils.init();
BeanUtils.init();
}
}
</code></pre>
<h2 id="using-pojo-as-query-parameters">Using POJO as query parameters</h2>
<h3 id="description">Description</h3>
<p>SpringBoot supports to map a bean parameter to HTTP queries.</p>
<pre><code class="language-java">@RequestMapping("/hello")
public class HelloService {
@RequestMapping(value = "/sayHello", method = RequestMethod.GET)
public String sayHello(Person person) {
System.out.println("sayHello is called, person = [" + person + "]");
return "Hello, your name is " + person.getName() + ", and age is " + person.getAge();
}
}
</code></pre>
<p>ServiceComb supports this usage too, but has following constraints.
1. Must not add any mapping annotations, such as <code>@QueryParam</code>
2. Only map to query parameters, headers and forms not supported.
3. Variables name in POJO definition must be the same as query keys.
4. Only primitive and String types supported in POJO, add <code>@JsonIgnore</code> to other types to ignore it.
5. In consumer site(e.g RestTemplate), still need to use query parameters, can not use POJO.</p>
<h3 id="examples">Examples</h3>
<h4 id="provider">Provider</h4>
<ul>
<li>service definition</li>
</ul>
<pre><code class="language-java"> @RestSchema(schemaId = "helloService")
@RequestMapping("/hello")
public class HelloService {
@RequestMapping(value = "/sayHello", method = RequestMethod.GET)
public String sayHello(Person person) {
System.out.println("sayHello is called, person = [" + person + "]");
return "Hello, your name is " + person.getName() + ", and age is " + person.getAge();
}
}
</code></pre>
<ul>
<li>parameters</li>
</ul>
<pre><code class="language-java"> public class Person {
private String name;
private int age;
@JsonIgnore // add @JsonIgnore to unsupported types
private List<Person> children;
}
</code></pre>
<ul>
<li>Schemas</li>
</ul>
<pre><code class="language-yaml">
basePath: "/hello"
paths:
/sayHello:
get:
operationId: "sayHello"
parameters:
# name and age is query parameter
- name: "name"
in: "query"
required: false
type: "string"
- name: "age"
in: "query"
required: false
type: "integer"
format: "int32"
responses:
200:
description: "response of 200"
schema:
type: "string"
</code></pre>
<h4 id="consumer">Consumer</h4>
<ul>
<li>Call using RPC</li>
<li>add an interface
<code>java
public interface HelloServiceIntf {
String sayHello(String name, int age);
}</code></li>
<li>call the interface
<code>java
String result = helloService.sayHello("Bob", 22); // result is "Hello, your name is Bob, and age is 22"</code></li>
<li>Call using RestTemplate
<code>java
String result = restTemplate.getForObject(
"cse://provider-service/hello/sayHello?name=Bob&age=22",
String.class);</code></li>
</ul>
<h2 id="servicecomb-suppoted-spring-mvc-annotations-and-differences">ServiceComb suppoted Spring MVC annotations and differences</h2>
<p>ServiceComb supports Spring MVC annotatioins(org.springframework.web.bind.annotation) to define REST interfaces, but they are different. ServiceComb do not support <code>@Controller</code> frameworks and only support <code>@RestController</code> frameworks.</p>
<ul>
<li>Differences in supported annotations</li>
</ul>
<h3 id="table-1-1-annotations">Table 1-1 annotations</h3>
<table>
<thead>
<tr>
<th align="left">annotation</th>
<th align="left">supported</th>
<th align="left">notes</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">RequestMapping</td>
<td align="left">Yes</td>
<td align="left">Can only have one path, multiple path is not supported.</td>
</tr>
<tr>
<td align="left">GetMapping</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">PutMapping</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">PostMapping</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">DeleteMapping</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">PatchMapping</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">RequestParam</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">CookieValue</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">PathVariable</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">RequestHeader</td>
<td align="left">Yes</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">RequestBody</td>
<td align="left">Yes</td>
<td align="left">supports application/json,plain/text</td>
</tr>
<tr>
<td align="left">RequestPart</td>
<td align="left">Yes</td>
<td align="left">Used in file upload. Using Part、MultipartFile annotations.</td>
</tr>
<tr>
<td align="left">ResponseBody</td>
<td align="left">No</td>
<td align="left">@Controller framework is not supported</td>
</tr>
<tr>
<td align="left">ResponseStatus</td>
<td align="left">No</td>
<td align="left">Using ApiResponse to define status code</td>
</tr>
<tr>
<td align="left">RequestAttribute</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">SessionAttribute</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">MatrixVariable</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">ModelAttribute</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">ControllerAdvice</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">CrossOrigin</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">ExceptionHandler</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">InitBinder</td>
<td align="left">No</td>
<td align="left"></td>
</tr>
</tbody>
</table>
<ul>
<li>Define a REST service</li>
</ul>
<p>Spring MVC using <code>@RestController</code> to define a REST service,ServiceComb using <code>@RestSchema</code> to define a REST service,and path value in <code>@RequestMapping</code> is required.</p>
<pre><code class="language-java">@RestSchema(schemaId = "hello")
@RequestMapping(path = "/")
</code></pre>
<p><code>@RestController</code> is also supported and equals to <code>@RestSchma(schemaId="class name")</code>. However we suggest using <code>@RestSchema</code> to define a schemaId,it's more convenient when used in configurations. </p>
<p><strong>Cautions</strong>: If the classes with <code>@RestController</code> are not expected to be processed by ServiceComb-Java-Chassis and work as REST services, the config item <code>servicecomb.provider.rest.scanRestController=false</code> can be specified to disable the feature mentioned above.</p>
<ul>
<li>Supported data types</li>
</ul>
<p>Spring MVC supports almost all java types in service difinition, e.g.</p>
<pre><code>// abstract class
public void postData(@RequestBody Object data)
// interface
public void postData(@RequestBody IPerson interfaceData)
// generic without types
public void postData(@RequestBody Map rawData)
// servlet types
public void postData(HttpServletRequest rquest)
</code></pre>
<p>ServiceComb need to generate Open API schemas based on definition, and support cross language features, so some of there usage is not supported.</p>
<p>HttpServletRequest,Object is supported in latest version, but they are different. We suggest not using there features if possible.</p>
<p>please refer to <a href="../interface-constraints/">API Constraints</a> for data type supports.</p>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href="../swagger-annotation/" class="btn btn-neutral float-left" title="Use Swagger annotations"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../jaxrs/" class="btn btn-neutral float-right" title="Develop with JAX-RS">Next <span class="icon icon-circle-arrow-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
</div>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span><a href="../swagger-annotation/" style="color: #fcfcfc">« Previous</a></span>
<span><a href="../jaxrs/" style="color: #fcfcfc">Next »</a></span>
</span>
</div>
<script>var base_url = '../..';</script>
<script src="../../js/theme_extra.js" defer></script>
<script src="../../js/theme.js" defer></script>
<script src="../../search/main.js" defer></script>
<script defer>
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
</script>
</body>
</html>