REST_返回形式

摘录:

  "Web resources" were first defined on the World Wide Web as documents or files identified by their URLs. However, today they have a much more generic and abstract definition that encompasses every thing or entity that can be identified, named, addressed, or handled, in any way whatsoever, on the web. In a RESTful web service, requests made to a resource's URI will elicit a response that may be in XML, HTML, JSON, or some other format. The response may confirm that some alteration has been made to the stored resource, and the response may provide hypertext links to other related resources or collections of resources. When HTTP is used, as is most common, the operations available are GET, POST, PUT, DELETE, and other predefined CRUD HTTP methods.

  • 返回HTML格式的响应

 

 1 @Controller
 2 //@RestController
 3 public class RestDemo {
 4 
 5     /**
 6      * 这里返回HTML
 7      * path和value属性可以在org.springframework.web.bind.annotation.RequestMapping看到
 8      * 这两个属性互相为别名
 9      * 且这两个属性都是数组,可以放多个可能的值
10      * 从spring4.3引入了GetMapping接口,简化RequestMapping对get请求的处理
11      * @RestController = @Controller + @ResponseBody()
12      */
13     //@RequestMapping(value={"/html/demo","/html/demo2"})
14     //@RequestMapping(path={"/html/demo","/html/demo2"})
15     @GetMapping(value={"html/demo3","html/demo4"})
16     @ResponseBody()
17     public String htmlCode(){
18         return "<html><body>hello world</body></html>";
19     }
20 }

 

 

 

  

 

转载于:https://www.cnblogs.com/rocker-pg/p/8975628.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值