用思想、知识和音乐去影响和改变

restful-post
<form action="http://localhost:8888/hello/count" method="post">
<input type="text" name="num"/>
<input type="submit" value="submit"/>

</form>


import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;


@Path("/hello")
public class HelloService {
private String count ;
@GET 
    @Produces("text/plain")
public String helloWorld(){
return "Hello world!";
}

@POST
@Path("sayhi")
@Consumes("application/x-www-form-urlencoded")
public String sayHello(@FormParam("msg")String name){
System.out.println("==============");
return "Hello "+name;
}
@POST
@Path("/count")
@Consumes("application/x-www-form-urlencoded")
public String counter(@FormParam("num")String num){
this.count = num;
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(count);
return count;
}
}

阅读更多
文章标签: string path action class
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

restful-post

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭