{"id":38530,"date":"2023-12-11T14:44:44","date_gmt":"2023-12-11T06:44:44","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=38530"},"modified":"2023-12-11T14:44:44","modified_gmt":"2023-12-11T06:44:44","slug":"%e8%af%b7%e8%af%b4%e6%98%8e%e4%b8%80%e4%b8%8bweb-xml%e6%96%87%e4%bb%b6%e4%b8%ad%e5%8f%af%e4%bb%a5%e9%85%8d%e7%bd%ae%e5%93%aa%e4%ba%9b%e5%86%85%e5%ae%b9%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e8%af%b7%e8%af%b4%e6%98%8e%e4%b8%80%e4%b8%8bweb-xml%e6%96%87%e4%bb%b6%e4%b8%ad%e5%8f%af%e4%bb%a5%e9%85%8d%e7%bd%ae%e5%93%aa%e4%ba%9b%e5%86%85%e5%ae%b9%ef%bc%9f\/","title":{"rendered":"\u8bf7\u8bf4\u660e\u4e00\u4e0bweb.xml\u6587\u4ef6\u4e2d\u53ef\u4ee5\u914d\u7f6e\u54ea\u4e9b\u5185\u5bb9\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u8003\u5bdf\u70b9\uff1axml\u6587\u4ef6<\/p>\n<p>\u00a0<\/p>\n<p>web.xml\u7528\u4e8e\u914d\u7f6eWeb\u5e94\u7528\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u5982\uff1a\u76d1\u542c\u5668\uff08listener\uff09\u3001\u8fc7\u6ee4\u5668\uff08filter\uff09\u3001 Servlet\u3001\u76f8\u5173\u53c2\u6570\u3001\u4f1a\u8bdd\u8d85\u65f6\u65f6\u95f4\u3001\u5b89\u5168\u9a8c\u8bc1\u65b9\u5f0f\u3001\u9519\u8bef\u9875\u9762\u7b49\uff0c\u4e0b\u9762\u662f\u4e00\u4e9b\u5f00\u53d1\u4e2d\u5e38\u89c1\u7684\u914d\u7f6e\uff1a<\/p>\n<p>\u2460\u914d\u7f6eSpring\u4e0a\u4e0b\u6587\u52a0\u8f7d\u76d1\u542c\u5668\u52a0\u8f7dSpring\u914d\u7f6e\u6587\u4ef6\u5e76\u521b\u5efaIoC\u5bb9\u5668\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;context-param&gt;<br \/>\n&lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;<br \/>\n&lt;param-value&gt;classpath:applicationContext.xml&lt;\/param-value&gt;<br \/>\n&lt;\/context-param&gt;<\/p>\n<p>&lt;listener&gt;<br \/>\n&lt;listener-class&gt;<br \/>\norg.springframework.web.context.ContextLoaderListener<br \/>\n&lt;\/listener-class&gt;<br \/>\n&lt;\/listener&gt;<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u2461\u914d\u7f6eSpring\u7684OpenSessionInView\u8fc7\u6ee4\u5668\u6765\u89e3\u51b3\u5ef6\u8fdf\u52a0\u8f7d\u548cHibernate\u4f1a\u8bdd\u5173\u95ed\u7684\u77db\u76fe\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;filter&gt;<br \/>\n&lt;filter-name&gt;openSessionInView&lt;\/filter-name&gt;<br \/>\n&lt;filter-class&gt;<br \/>\norg.springframework.orm.hibernate3.support.OpenSessionInViewFilter<br \/>\n&lt;\/filter-class&gt;<br \/>\n&lt;\/filter&gt;<\/p>\n<p>&lt;filter-mapping&gt;<br \/>\n&lt;filter-name&gt;openSessionInView&lt;\/filter-name&gt;<br \/>\n&lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;<br \/>\n&lt;\/filter-mapping&gt;<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u2462\u914d\u7f6e\u4f1a\u8bdd\u8d85\u65f6\u65f6\u95f4\u4e3a10\u5206\u949f\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;session-config&gt;<br \/>\n&lt;session-timeout&gt;10&lt;\/session-timeout&gt;<br \/>\n&lt;\/session-config&gt;<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u2463\u914d\u7f6e404\u548cException\u7684\u9519\u8bef\u9875\u9762\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;error-page&gt;<br \/>\n&lt;error-code&gt;404&lt;\/error-code&gt;<br \/>\n&lt;location&gt;\/error.jsp&lt;\/location&gt;<br \/>\n&lt;\/error-page&gt;<\/p>\n<p>&lt;error-page&gt;<br \/>\n&lt;exception-type&gt;java.lang.Exception&lt;\/exception-type&gt;<br \/>\n&lt;location&gt;\/error.jsp&lt;\/location&gt;<br \/>\n&lt;\/error-page&gt;<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u2464\u914d\u7f6e\u5b89\u5168\u8ba4\u8bc1\u65b9\u5f0f\uff1a<\/p>\n<p>\u2464\u914d\u7f6e\u5b89\u5168\u8ba4\u8bc1\u65b9\u5f0f\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;security-constraint&gt;<br \/>\n&lt;web-resource-collection&gt;<br \/>\n&lt;web-resource-name&gt;ProtectedArea&lt;\/web-resource-name&gt;<br \/>\n&lt;url-pattern&gt;\/admin\/*&lt;\/url-pattern&gt;<br \/>\n&lt;http-method&gt;GET&lt;\/http-method&gt;<br \/>\n&lt;http-method&gt;POST&lt;\/http-method&gt;<br \/>\n&lt;\/web-resource-collection&gt;<br \/>\n&lt;auth-constraint&gt;<br \/>\n&lt;role-name&gt;admin&lt;\/role-name&gt;<br \/>\n&lt;\/auth-constraint&gt;<br \/>\n&lt;\/security-constraint&gt;<\/p>\n<p>&lt;login-config&gt;<br \/>\n&lt;auth-method&gt;BASIC&lt;\/auth-method&gt;<br \/>\n&lt;\/login-config&gt;<\/p>\n<p>&lt;security-role&gt;<br \/>\n&lt;role-name&gt;admin&lt;\/role-name&gt;<br \/>\n&lt;\/security-role&gt;<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u8003\u5bdf\u70b9\uff1axml\u6587\u4ef6 \u00a0 web.xml\u7528\u4e8e\u914d\u7f6eWeb\u5e94\u7528\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u5982\uff1a\u76d1\u542c\u5668 [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-38530","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=38530"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38530\/revisions"}],"predecessor-version":[{"id":38531,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38530\/revisions\/38531"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=38530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=38530"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=38530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}