<commit_before>示例3: 进阶二 - Restful API与带参服务
====

####1、修改HelloWorldComponent，添加Restful风格服务
######1.1、添加接口
```java
import org.nanoframework.core.component.stereotype.bind.PathVariable;
import org.nanoframework.core.component.stereotype.bind.RequestMethod;
...

@RequestMapping(value = "/hello/{value}", method = RequestMethod.GET)
Object byRestfulApiByGet(@PathVariable("value") String value);
```

######1.2、添加实现
```java
@Override
public Object byRestfulApiByGet(String value) {
	return "Hello Nano Framework by Restful API and GET method, this value is " + value;
}
```

######1.3、验证Restful
* 启动服务并访问http://ip:port/first-webapp/first/hello/test
* 返回结果: Hello Nano Framework by Restful API and GET method, this value is test

####2、修改HelloWorldComponent，添加带参数的Restful风格服务
######2.1、添加接口
```java
import org.nanoframework.core.component.stereotype.bind.RequestParam;
...

@RequestMapping(value = "/hello/{value}", method = RequestMethod.GET)
Object byRestfulApiByGetParam(@PathVariable("value") String value, @RequestParam(name = "name") String name);
```

######2.2、添加实现
```java
@Override
public Object byRestfulApiByGetParam(String value, String name) {
	return "Hello Nano Framework by Restful API and GET method, this value is " + value + " and name is " + name;
}
```
######2.3、验证Restful
* 启动服务并访问http://ip:port/first-webapp/first/hello/test?name=hello
* 返回结果: Hello Nano Framework by Restful API and GET method, this value is test and name is hello


[上一节](nano-examples/examples/examples-01.md)

[下一节](nano-examples/examples/examples-03.md)<commit_msg>modify examples-02<commit_after>示例3: 进阶二 - Restful API与带参服务
====

####1、修改HelloWorldComponent，添加Restful风格服务
######1.1、添加接口
```java
import org.nanoframework.core.component.stereotype.bind.PathVariable;
import org.nanoframework.core.component.stereotype.bind.RequestMethod;
...

@RequestMapping(value = "/hello/{value}", method = RequestMethod.GET)
Object byRestfulApiByGet(@PathVariable("value") String value);
```

######1.2、添加实现
```java
@Override
public Object byRestfulApiByGet(String value) {
	return "Hello Nano Framework by Restful API and GET method, this value is " + value;
}
```

######1.3、验证Restful
* 启动服务并访问http://ip:port/first-webapp/first/hello/test
* 返回结果: Hello Nano Framework by Restful API and GET method, this value is test

####2、修改HelloWorldComponent，添加带参数的Restful风格服务
######2.1、添加接口
```java
import org.nanoframework.core.component.stereotype.bind.RequestParam;
...

@RequestMapping(value = "/hello/{value}", method = RequestMethod.GET)
Object byRestfulApiByGetParam(@PathVariable("value") String value, @RequestParam(name = "name") String name);
```

######2.2、添加实现
```java
@Override
public Object byRestfulApiByGetParam(String value, String name) {
	return "Hello Nano Framework by Restful API and GET method, this value is " + value + " and name is " + name;
}
```
######2.3、验证Restful
* 启动服务并访问http://ip:port/first-webapp/first/hello/test?name=hello
* 返回结果: Hello Nano Framework by Restful API and GET method, this value is test and name is hello


[上一节](examples-01.md)

[下一节](examples-03.md)
{'fraction_non_alphanumeric': 0.15457207940123657, 'fraction_numerical': 0.013016596160104133, 'mean_word_length': 5.939051918735892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5815345', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1127, 'n_words': 244}