¾«Í¨Grails: RESTful Grails - ±à³ÌÈëÃÅÍø
port/list£¬²¢ÑéÖ¤ Accept ±¨Í·ÕýÔÚÇëÇó text/xml ¡£Õâ¾ÍÊÇ×ÊÔ´µÄ MIME ÀàÐÍÁË¡£
ÄÇô£¬Grails ÊÇÈçºÎÏìÓ¦·þÎñÆ÷¶ËµÄ Accept ±¨Í·µÄÄØ£¿ÔÙÏò AirportController Ìí¼ÓÒ»¸ö±Õ°ü£¬ ÈçÇåµ¥ 4 Ëùʾ£º Çåµ¥ 4. debugAccept ²Ù×÷
Çåµ¥ 4 ÖеĵÚÒ»ÐдÓÇëÇóÖмìË÷³öÁË Accept ±¨Í·¡£µÚ¶þÐÐչʾÁË Grails ÈçºÎת»»ÇëÇóºÍËü½«Òª·¢ »ØµÄÏìÓ¦¡£ ÏÖÔÚ£¬Ê¹Óà cURL À´×öÏàͬµÄËÑË÷£¬ÈçÇåµ¥ 5 Ëùʾ£º Çåµ¥ 5. µ÷ÊÔ cURL ÖÐµÄ Accept ±¨Í·
¾«Í¨Grails: RESTful Grails(6)ʱ¼ä:2011-07-29 IBM Scott Davisall ºÍ xml ÖµÊÇÄÄÀ´µÄÄØ£¿¿´Ò»Ï grails-app/conf/Config.groovy¡£ÔÚÎļþ¶¥²¿£¬ÄúÓ¦¸Ã¿´µ½ÁËÒ» ¸öÉ¢ÁÐÓ³É䣬Ëü¶ÔËùÓеļü¶¼Ê¹ÓÃÁ˼òµ¥Ãû³Æ£¨Ïñ all ºÍ xml ÕâÑùµÄÃû³Æ£©£¬¶øÇÒËùÓеÄÖµ¶¼Ê¹ÓÃÁËÓë Ö®¶ÔÓ¦µÄ MIME ÀàÐÍ¡£Çåµ¥ 6 չʾÁË grails.mime.types É¢ÁÐÓ³É䣺 Çåµ¥ 6. Config.groovy ÖÐµÄ grails.mime.types É¢ÁÐ
µäÐ굀 Web ä¯ÀÀÆ÷ÌṩµÄ Accept ±¨Í·Òª±ÈÄúÓë cURL Ò»ÆðʹÓõÄÉÔ΢¸´ÔÓЩ¡£ÀýÈ磬Mac OS X 10.5.4 É쵀 Firefox 3.0.1 ÌṩµÄ Accept ±¨Í·´óÖÂÊÇÕâÑùµÄ£º text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ËüÊÇÒ»¸öÓöººÅ¸ô¿ªµÄÁÐ±í£¬Ëü´øÓпÉÑ¡µÄ q ÊôÐÔ£¬ÓÃÒÔÖ§³Ö MIME ÀàÐÍ£¨q Öµ — quality µÄËõд — ÊÇ float Öµ£¬·¶Î§ÊÇ 0.0 µ½ 1.0£©¡£ÓÉÓÚ application/xml ±»¸³ÓèÁËÒ»¸öΪ 0.9 µÄ q Öµ£¬ËùÒÔÓë ÆäËûÀàÐ͵ÄÊý¾ÝÏà±È£¬Firefox ¸üÆ«ºÃ XML Êý¾Ý¡£ ÏÂÃæÊÇ Mac OS X 10.5.4 É쵀 Safari 3.1.2 °æ±¾ÌṩµÄ accept ±¨Í·£º
text/html MIME ÀàÐͱ»¸³ÓèÁËÒ»¸öΪ 0.9 µÄ q Öµ£¬ËùÒÔÊ×Ñ¡µÄÊä³öÀàÐÍÊÇ HTML£¬0.8 ʱΪ text/plain£¬0.5 ʱΪ */*¡£ ÄÇô£¬ÏÖÔÚÄúÓ¦¸Ã¶ÔÄÚÈÝÐÉÌÓÐÁ˸ü¶àµÄÁ˽âÁË£¬Äú¿ÉÒÔ½« withFormat ¿éÌí¼Óµ½ list ²Ù×÷£¬ÒÔ´Ë À´ÒÀ¾ÝÇëÇóÖÐµÄ Accept ±¨Í··µ»ØºÏÊʵÄÊý¾ÝÀàÐÍ£¬ÈçÇåµ¥ 7 Ëùʾ£º Çåµ¥ 7. ÔÚÒ»¸ö²Ù×÷ÖÐʹÓà withFormat ¿é
|
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |