REST¼Ü¹¹ÓëJavaʵÏÖ1——REST¸ÅÄî
ÓÉÓÚÓиöºÏ×÷ÏîÄ¿£¬Óõ½ÁËREST£¬ÎÒÃÇÕâ±ßµÄ·þÎñÆ÷ÊÇjavaµÄ£¬ºÏ×÷·½ÄDZßÖ÷ÒªÊÇPHP»·¾³£¬ÎªÁËÔ¶³Ìµ÷ÓõÄÎÊÌ⣬ʹÓÃÁËREST×÷ΪAPIµÄʵÏÖ·½
°¸¡£ÏÖÔÚÏîÄ¿×öµÃ²î²»¶àÁË£¬ÏÂÃæ¼ÇÏÂ×Ô¼ºµÄÒ»µãÐĵã¬ËãÊDZʼǰɡ£
REST£¨Representational State Transfer£©µÄ˵·¨À´×Ô“Architectural Styles and the Design of Network-based
Software Architectures”
£¨Roy Fielding£¬University of California -
Irvine£¬2000£©£¬ÊÇFielding´óÅ£µÄһƪ²©Ê¿ÂÛÎÄ£¬´ÓÍøÉÏËÑË÷ÏÂÓ¦¸Ã¿ÉÒÔÕÒµ½ÖÐÎÄ°æ¡£Ê×ÏÈREST¸ù±¾²»ÊǸö¼¼Êõ£¬Ö»ÊÇÒ»¸ö¼Ü¹¹·½Ê½µÄ×Ü
³Æ£¬¸úweb
serviceҲû̫´ó¹Øϵ£¬Ö»ÊÇ´ÕÇÉËü¿ÉÒÔÂú×ã×î¼òµ¥µÄÔ¶³ÌÐÅÏ¢»ñÈ¡µÄÐèÒª¡£RESTÒ²ÍêÈ«²»ÊÇж«Î÷£¬ÆäʵÔçÆÚµÄHTML¾²Ì¬ÍøÒ³¶¼ÊÇREST£¬Ö»²»
¹ýËæן÷ÖÖ¶¯Ì¬½Å±¾ÓïÑÔµÄʹÓ㬻¥ÁªÍøµÄ¼Ü¹¹Ò²Æ«ÀëÁËÔçÆÚµÄÉ趨£¬RESTµ¹ÊÇÓе㲦ÂÒ·´ÕýµÄζµÀ¡£
RESTµÄÖ÷ÒªÌØÕ÷°üÀ¨£º
1£¬ËùÓеĶ«Î÷¶¼ÊÇ×ÊÔ´£¬×ÊÔ´ÓÃURI±íʾ£¬Ã¿Ò»¸ö»á»°¶¼ÊÇÎÞ״̬µÄ¡£
Õâ¾ä»°É¶Òâ˼£¬¼ÇµÃÒÔÇ°µÄ¾²Ì¬ÍøÒ³²»£¬http://localhost/hello.jspÕâʵ¼Ê¾ÍÊÇÒ»¸ö×ÊÔ´£¬Õâ¸öURI¾ÍÊÇËûµÄµØÖ·¡£Äã¿Ï
¶¨ËµÕâô¼òµ¥»¹ÓÃѧREST£¿£¬¶Ô£¬REST¾ÍÊÇÕâô¼òµ¥£¬µ«ÊÇÇé¿öÔÙ¸´ÔÓÒ»µã£¬±ÈÈçҪд¸ö¹ºÂòÉÌÆ·µÄÒ³Ã棬ÔÛÃÇÓÃJSF»òÕßstruts£¬´Óºǫ́
SessionÈ¡¸ö¿Í»§ID£¬ÔÙ´Ó¹ºÎï³µÀïÍ·°ÑÉÌÆ·ÁбíÈ¡³öÀ´£¬ÎÒÃǸßÐ˵ÄдÁËÒ»¸öhttp://localhost/buyProduct.doÍê³ÉÁË
Õâ¸ö¹¦ÄÜ£¬ÄÇôÕâ¸öhttp://localhost/buyProduct.doµÄURI¾Í²»ÊÇRESTÁË£¬ËûÒÀÀµÓÚÔËÐÐʱ»·¾³ºÍSessionÀïµÄ±ä
Á¿£¬ÕâÑùµÄURI²»Äܱ»Öظ´Ö´ÐУ¬Ò²¾ÍÊÇ˵ֱ½ÓÕ³µ½ä¯ÀÀÆ÷ÔËÐп϶¨Òª±¨´íµÄ¡£ÊDz»ÊÇRESTÒ²ºÜÈÝÒ׿´£¬ÕâÍæÒâͨ¹ýURIÄÜ·ÃÎʲ»£¬ÄÜ·ÃÎʾÍÊÇREST¡£
2£¬¹«¿ªÄ¿Â¼½á¹¹Ê½µÄ URI
¿´ÁËÉÏÃæÄǸöÀý×Ó£¬ÄÇôÔõôдÕâ¸öURIÄØ£¬ÆäʵRESTÏ£ÍûµÄURIÊDzÉÓÃĿ¼½á¹¹Ê½µÄURI£¬ÓÃÒ»ÖÖ´ø²ã´ÎµÄ½á¹¹±íʾ¶Ô×ÊÔ´µÄ»ñÈ¡£¬±ÈÈçÎÒÒª
»ñÈ¡ÂÛ̳µÄÒ»¸ötopic£¬URIµÄ¶¨Òå¾Í¿ÉÒÔ±íʾ³Éhttp://localhost/discussion/topics/103£¬ÔÚÕâÀï
topics¾ÍÊÇÉÏÎÄÎÒÃÇ˵µ½µÄ×ÊÔ´£¬ºóÃæµÄ103ÊÇ×ÊÔ´µÄID¡£ÕâÑùµÄURI¼ò½àÃÀ¹Û£¬ËÑË÷ÒýÇæÓѺ㬿ÉÒÔ±»ä¯ÀÀÆ÷»º´æ£¬Óë»á»°×´Ì¬Î޹أ¬È»ºóÄã¿ÉÄÜÒª
ÎÊÁË£¬ÄÇÎÒÒÔǰдµÄhttp://localhost/discussion/topics?id=103ÕâÑùµÄURIÄØ£¿ÆäʵÕâÖÖÒ²¿ÉÒÔËã
REST£¬URIµÄ±íʾ·½Ê½ÊÇÓÉ¿ª·¢Õß¾ö¶¨µÄ£¬µ±È»http://localhost/discussion/topics?id=103ÕâÖÖд·¨Ëƺõ¶Ô
ËÑË÷ÒýÇæ²
Ïà¹ØÎĵµ£º
ÒÆλÔËËã·û
°üÀ¨£º
“>> ÓÒÒÆ”£»“<< ×óÒÆ”£»“>>> ÎÞ·ûºÅÓÒÒÆ”
Àý×Ó£º
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 1011
1111 1111 1111 1111 1111 1111 1111 1111
Æä½á¹ûÓë Math.floor((double)- ......
²»¹ÜÄãÐŲ»ÐÅ£¬¼´Ê¹¶àôÊìÁ·±à³ÌµÄÈËÔ±ÔÚcodingµÄʱºò¶¼»á³öÏÖÒâÏë²»µ½µÄbug¡£ÔÚÉÏƪÎÄÕÂÖÐÎÒÔøÌáµ½£¬bugµÄÔì³ÉÊǶà¸ö·½ÃæµÄ×ۺϽá¹û£¬ÓÐЩbugÊÇ¿ÉÒÔÐÞ¸´µÄ£¬µ«ÊÇÓÐЩÂß¼ÉϵÄbugÒªÐÞ¸´¿É²»ÊÇÄÇôÈÝÒ×µÄÊÂÇ飬¾ÍÏñÎÒÃÇ×ö´íÁËÒ»¼þÊÂÇ飬Èç¹û²»È¥´Ó¸ù±¾ÉϸÄÕý¾Í»á·¸¸ü´óµÄ´íÎóÒ»Ñù£¬ÓÐʱºòbugÒ²ÊÇÒ»¸ö»ýÀ ......
Ò»¸öÈí¼þÉè¼ÆµÄºÃ»µ£¬ÎÒÏëºÜ´ó³Ì¶ÈÉÏÈ¡¾öÓÚËüµÄÕûÌå¼Ü¹¹£¬¶øÕâ¸öÕûÌå¼Ü¹¹Æäʵ¾ÍÊÇÄã¶ÔÕû¸öºê¹ÛÉÌÒµÒµÎñµÄ³éÏó¿ò¼Ü£¬µ±´ú±íÒµÎñÂß¼µÄ¸ß²ã³éÏó²ã½á¹¹ ºÏÀíʱ£¬Äãµ×²ãµÄ¾ßÌåʵÏÖÐèÒª¿¼Âǵľͽö½öÊÇһЩËã·¨ºÍһЩ¾ßÌåµÄÒµÎñʵÏÖÁË¡£µ±ÄãÐèÒªÔÙ¿ª·¢ÁíÒ»¸öÏà½üµÄÏîĿʱ£¬ÄãÒÔÇ°µÄ³éÏó²ã˵²»¶¨»¹¿ÉÒÔÔÙ´ÎÀûÓà ÄØ£¬Ãæ¶Ô¶ÔÏóµÄÉè¼Æ ......
eclipseÑ¡Ò»¸ö±äÁ¿ºó£¬Õâ¸öÀàÀïµÄ¸Ã±äÁ¿²»±äÉ«ÎÊÌâ½â¾ö£º
alt + shift + o
/**
* дÈëÈÕÖ¾
* filePath ÈÕÖ¾ÎļþµÄ·¾¶
* code ҪдÈëÈÕÖ¾ÎļþµÄÄÚÈÝ
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......