Skip to content

Commit 4130c21

Browse files
authored
Update README.md
1 parent 3f3234c commit 4130c21

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,50 @@ In this project you can fast publish your API and schedule task, dynamic edit yo
8787
![https://raw.githubusercontent.com/wiki/NLPchina/Jcoder/3.png](https://raw.githubusercontent.com/wiki/NLPchina/Jcoder/3.png)
8888

8989

90+
*** how to use example by action
91+
92+
````
93+
package org.nlpcn.jcoder.run.java;
94+
95+
import org.nlpcn.jcoder.run.annotation.Cache;
96+
97+
/**
98+
* this is a api example
99+
*
100+
* @author ansj
101+
*
102+
*/
103+
@Single(false) // default is true
104+
public class ApiExampleAction {
105+
106+
@Inject
107+
private Logger log ;
108+
109+
@Inject
110+
private Dao dao ;
111+
112+
@Execute // publish this function to api !
113+
// use url is
114+
// http://host:port/[className]/methodName?field=value
115+
// http//localhost:8080/ApiExampleAction/method?name=heloo&hello_word=hi
116+
public Object function(HttpServletRequest req, HttpServerResponse rep, String name, @Param("hello_word") Integer helloWord) {
117+
dosomething..
118+
}
119+
120+
@DefaultExecute // publish this function to api !
121+
//http://localhost:8080/ApiExampleAction?user.name=aaa&user.passowrd=bbb
122+
//http://localhost:8080/ApiExampleAction/function2?user.name=aaa&user.passowrd=bbb
123+
//more about http://www.nutzam.com/core/mvc/http_adaptor.html
124+
125+
@Cache(time=10,size=1000,block=false) // time SECONDS , block if false use asynchronous
126+
public Object function2(@Param("..") User user) {
127+
128+
dosomething..
129+
}
130+
131+
}
132+
133+
````
134+
135+
90136
* [创建中文分词服务例子](http://www.jianshu.com/p/1fcf5327107a)

0 commit comments

Comments
 (0)