(window.webpackJsonp=window.webpackJsonp||[]).push([[240],{469:function(a,t,s){"use strict";s.r(t);var e=s(42),n=Object(e.a)({},(function(){var a=this,t=a.$createElement,s=a._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":a.$parent.slotKey}},[s("h1",{attrs:{id:"请求参数缓存"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#请求参数缓存"}},[a._v("#")]),a._v(" 请求参数缓存")]),a._v(" "),s("p",[a._v("在默认情况下,在接口调试的情况下,"),s("code",[a._v("Knifetj")]),a._v("对于接口的请求参数都会缓存起来，该配置可以在前端界面中的个性化设置中看到,如下图：")]),a._v(" "),s("blockquote",[s("p",[a._v("如果你不喜欢在调试的时候对参数进行缓存,可以在个性化设置中将该选项取消")])]),a._v(" "),s("p",[s("img",{attrs:{src:"/knife4j/images/knife4j/plus/cacheparameter.png",alt:""}})]),a._v(" "),s("p",[a._v("缓存的情况只会在后端没有给属性"),s("code",[a._v("example")]),a._v("的情况下产生,如果后端在写Swagger的注解的时候,给每个字段赋予了example的值,那么,"),s("code",[a._v("Knife4j")]),a._v("不会使用调试时缓存的值,而是会一直使用后端的example值")]),a._v(" "),s("p",[a._v("例如后端Java实体类如下情况：")]),a._v(" "),s("div",{staticClass:"language-java extra-class"},[s("pre",{pre:!0,attrs:{class:"language-java"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("public")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("class")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("SwaggerRequestBody")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n    \n    "),s("span",{pre:!0,attrs:{class:"token annotation punctuation"}},[a._v("@ApiModelProperty")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("value"),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[a._v('"姓名"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v("example"),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[a._v('"张飞"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n    "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("private")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("String")]),a._v(" name"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    \n    "),s("span",{pre:!0,attrs:{class:"token comment"}},[a._v("//more...")]),a._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n")])])]),s("p",[a._v("对于上面的代码示例,"),s("code",[a._v("Knife4j")]),a._v("在每一次打开该接口的请求参数值,其默认值都是"),s("code",[a._v("张飞")])]),a._v(" "),s("p",[a._v("以下情况会在第二次请求的情况下启用上一次调试时填的缓存值")]),a._v(" "),s("div",{staticClass:"language-java extra-class"},[s("pre",{pre:!0,attrs:{class:"language-java"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("public")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("class")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("SwaggerRequestBody")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n    \n    "),s("span",{pre:!0,attrs:{class:"token annotation punctuation"}},[a._v("@ApiModelProperty")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("value"),s("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[a._v('"姓名"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n    "),s("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("private")]),a._v(" "),s("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("String")]),a._v(" name"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    \n    "),s("span",{pre:!0,attrs:{class:"token comment"}},[a._v("//more...")]),a._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n")])])]),s("p",[a._v("这种情况在ui界面不会出现默认值,所以当开发者在调试的时候,填了name属性的值后,"),s("code",[a._v("Knife4j")]),a._v("就会将该值缓存起来,方便下次调试调用.")]),a._v(" "),s("comment-comment")],1)}),[],!1,null,null,null);t.default=n.exports}}]);