JSON MVC yog dab tsi?
JSON MVC yog dab tsi?

Video: JSON MVC yog dab tsi?

Video: JSON MVC yog dab tsi?
Video: Spring MVC Tutorials 34 - Web Services 04 ( Important JSON REST API Annotations...) 2024, Kaum ib hlis
Anonim

" JSON " (JavaScript Object Notation) yog cov ntawv nyeem yooj yim-raws li qhib qauv tsim los rau tib neeg-nyeem tau cov ntaub ntawv sib hloov. Thaum ua haujlwm ua ke nrog "jQuery" thiab "ASP. NET MVC " hauv kev tsim lub vev xaib, nws muab cov txheej txheem zoo los pauv cov ntaub ntawv ntawm lub vev xaib browser thiab lub vev xaib server.

Kuj kom paub yog, dab tsi yog rov qab JSON hauv MVC?

JsonResult yog ib yam ntawm MVC yam tshwm sim uas rov qab los cov ntaub ntawv rov qab mus rau qhov pom lossis browser hauv daim ntawv ntawm JSON (JavaScript Object notation format).

Ib yam li ntawd, ActionResult puas tuaj yeem rov qab JSON? ActionResult yog ib chav kawm paub daws teeb meem uas ua tuaj yeem rov qab los . Siv JsonResult thaum koj xav tau rov qab los raw JSON cov ntaub ntawv yuav tsum tau noj los ntawm tus neeg siv khoom (javascript ntawm nplooj ntawv web lossis tus neeg siv xov tooj ntawm tes).

Ua raws li qhov xav tau, JsonResult hom hauv MVC yog dab tsi?

JsonResult yog ActionResult ntaus hauv MVC . Nws pab xa cov ntsiab lus hauv JavaScript Object Notation ( JSON ) format. Hauv tsab xov xwm no, kuv yuav piav qhia yuav ua li cas nkag mus rau cov ntaub ntawv los ntawm a JsonResult khoom thiab tso saib nws hauv browser nrog piv txwv.

Dab tsi yog JSON thov Tus Cwj Pwm?

Yog koj xav tau xa JSON Hauv kev teb rau GET, koj yuav tsum tau tso cai rau tus cwj pwm los ntawm kev siv JsonRequestBehavior. AllowGet raws li qhov thib ob parameter rau lub Json txoj kev. Txawm li cas los xij, muaj lub caij nyoog uas tus neeg siv siab phem tuaj yeem nkag mus rau qhov JSON payload los ntawm cov txheej txheem hu ua JSON Kev nyiag.

Pom zoo: