JSP EL\u4e2d\u7684\u51fd\u6570<\/strong><\/div>\nJSP EL\u5141\u8bb8\u60a8\u5728\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u51fd\u6570\u3002\u8fd9\u4e9b\u51fd\u6570\u5fc5\u987b\u88ab\u5b9a\u4e49\u5728\u81ea\u5b9a\u4e49\u6807\u7b7e\u5e93\u4e2d\u3002\u51fd\u6570\u7684\u4f7f\u7528\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n
${ns:func(param1, param2, ...)}<\/pre>\nns\u6307\u7684\u662f\u547d\u540d\u7a7a\u95f4\uff08namespace\uff09\uff0cfunc\u6307\u7684\u662f\u51fd\u6570\u7684\u540d\u79f0\uff0cparam1\u6307\u7684\u662f\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0cparam2\u6307\u7684\u662f\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u6bd4\u5982\uff0c\u6709\u51fd\u6570fn:length\uff0c\u5728JSTL\u5e93\u4e2d\u5b9a\u4e49\uff0c\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u6765\u83b7\u53d6\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff1a<\/p>\n
${fn:length(\"Get my length\")}<\/pre>\n\u8981\u4f7f\u7528\u4efb\u4f55\u6807\u7b7e\u5e93\u4e2d\u7684\u51fd\u6570\uff0c\u60a8\u9700\u8981\u5c06\u8fd9\u4e9b\u5e93\u5b89\u88c5\u5728\u670d\u52a1\u5668\u4e2d\uff0c\u7136\u540e\u4f7f\u7528\u6807\u7b7e\u5728JSP\u6587\u4ef6\u4e2d\u5305\u542b\u8fd9\u4e9b\u5e93\u3002<\/p>\nJSP EL\u9690\u542b\u5bf9\u8c61<\/strong><\/div>\nJSP EL\u652f\u6301\u4e0b\u8868\u5217\u51fa\u7684\u9690\u542b\u5bf9\u8c61\uff1a<\/p>\n
\n\n\n\n\t\t\t\t\u9690\u542b\u5bf9\u8c61<\/strong><\/th>\n\n\t\t\t\t\u63cf\u8ff0<\/strong><\/th>\n<\/tr>\n\n\n\t\t\t\tpageScope<\/td>\n | \n\t\t\t\tpage \u4f5c\u7528\u57df<\/td>\n<\/tr>\n | \n\n\t\t\t\trequestScope<\/td>\n | \n\t\t\t\trequest \u4f5c\u7528\u57df<\/td>\n<\/tr>\n | \n\n\t\t\t\tsessionScope<\/td>\n | \n\t\t\t\tsession \u4f5c\u7528\u57df<\/td>\n<\/tr>\n | \n\n\t\t\t\tapplicationScope<\/td>\n | \n\t\t\t\tapplication \u4f5c\u7528\u57df<\/td>\n<\/tr>\n | \n\n\t\t\t\tparam<\/td>\n | \n\t\t\t\tRequest \u5bf9\u8c61\u7684\u53c2\u6570\uff0c\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n | \n\n\t\t\t\tparamValues<\/td>\n | \n\t\t\t\tRequest\u5bf9\u8c61\u7684\u53c2\u6570\uff0c\u5b57\u7b26\u4e32\u96c6\u5408<\/td>\n<\/tr>\n | \n\n\t\t\t\theader<\/td>\n | \n\t\t\t\tHTTP \u4fe1\u606f\u5934\uff0c\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n | \n\n\t\t\t\theaderValues<\/td>\n | \n\t\t\t\tHTTP \u4fe1\u606f\u5934\uff0c\u5b57\u7b26\u4e32\u96c6\u5408<\/td>\n<\/tr>\n | \n\n\t\t\t\tinitParam<\/td>\n | \n\t\t\t\t\u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u53c2\u6570<\/td>\n<\/tr>\n | \n\n\t\t\t\tcookie<\/td>\n | \n\t\t\t\tCookie\u503c<\/td>\n<\/tr>\n | \n\n\t\t\t\tpageContext<\/td>\n | \n\t\t\t\t\u5f53\u524d\u9875\u9762\u7684pageContext<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u60a8\u53ef\u4ee5\u5728\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u5bf9\u8c61\uff0c\u5c31\u50cf\u4f7f\u7528\u53d8\u91cf\u4e00\u6837\u3002\u63a5\u4e0b\u6765\u4f1a\u7ed9\u51fa\u51e0\u4e2a\u4f8b\u5b50\u6765\u66f4\u597d\u7684\u7406\u89e3\u8fd9\u4e2a\u6982\u5ff5\u3002<\/p>\n pageContext\u5bf9\u8c61<\/strong><\/div>\npageContext\u5bf9\u8c61\u662fJSP\u4e2dpageContext\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u901a\u8fc7pageContext\u5bf9\u8c61\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95eerequest\u5bf9\u8c61\u3002\u6bd4\u5982\uff0c\u8bbf\u95eerequest\u5bf9\u8c61\u4f20\u5165\u7684\u67e5\u8be2\u5b57\u7b26\u4e32\uff0c\u5c31\u50cf\u8fd9\u6837\uff1a<\/p>\n $<\/span>{<\/span>pageContext<\/span>.<\/span>request<\/span>.<\/span>queryString<\/span>}<\/span><\/pre>\nScope\u5bf9\u8c61<\/strong><\/div>\npageScope\uff0crequestScope\uff0csessionScope\uff0capplicationScope\u53d8\u91cf\u7528\u6765\u8bbf\u95ee\u5b58\u50a8\u5728\u5404\u4e2a\u4f5c\u7528\u57df\u5c42\u6b21\u7684\u53d8\u91cf\u3002<\/p>\n \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u60a8\u9700\u8981\u663e\u5f0f\u8bbf\u95ee\u5728applicationScope\u5c42\u7684box\u53d8\u91cf\uff0c\u53ef\u4ee5\u8fd9\u6837\u6765\u8bbf\u95ee\uff1aapplicationScope.box\u3002<\/p>\n param\u548cparamValues\u5bf9\u8c61<\/strong><\/div>\nparam\u548cparamValues\u5bf9\u8c61\u7528\u6765\u8bbf\u95ee\u53c2\u6570\u503c\uff0c\u901a\u8fc7\u4f7f\u7528request.getParameter\u65b9\u6cd5\u548crequest.getParameterValues\u65b9\u6cd5\u3002<\/p>\n \u4e3e\u4f8b\u6765\u8bf4\uff0c\u8bbf\u95ee\u4e00\u4e2a\u540d\u4e3aorder\u7684\u53c2\u6570\uff0c\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\u8868\u8fbe\u5f0f\uff1a${param.order}\uff0c\u6216\u8005${param[\"order\"]}\u3002<\/p>\n \u63a5\u4e0b\u6765\u7684\u4f8b\u5b50\u8868\u660e\u4e86\u5982\u4f55\u8bbf\u95eerequest\u4e2d\u7684username\u53c2\u6570\uff1a<\/p>\n <%@<\/span> page <\/span>import<\/span>=<\/span>\"java.io.*,java.util.*\"<\/span> %>\r\n<\/span><%<\/span>\r\n <\/span>String<\/span> title <\/span>=<\/span> <\/span>\"Accessing Request Param\"<\/span>;<\/span>\r\n%>\r\n<\/span><html><\/span>\r\n<\/span><head><\/span>\r\n<\/span><title><\/span><%<\/span> <\/span>out<\/span>.<\/span>print<\/span>(<\/span>title<\/span>);<\/span> %><\/span><\/title><\/span>\r\n<\/span><\/head><\/span>\r\n<\/span><body><\/span>\r\n<\/span><center><\/span>\r\n<\/span><h1><\/span><%<\/span> <\/span>out<\/span>.<\/span>print<\/span>(<\/span>title<\/span>);<\/span> %><\/span><\/h1><\/span>\r\n<\/span><\/center><\/span>\r\n<\/span><div<\/span> <\/span>align<\/span>=<\/span>\"center\"<\/span>><\/span>\r\n<\/span><p><\/span>${param[\"username\"]}<\/span><\/p><\/span>\r\n<\/span><\/div><\/span>\r\n<\/span><\/body><\/span>\r\n<\/span><\/html><\/span><\/pre>\nparam\u5bf9\u8c61\u8fd4\u56de\u5355\u4e00\u7684\u5b57\u7b26\u4e32\uff0c\u800cparamValues\u5bf9\u8c61\u5219\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<\/p>\n header\u548cheaderValues\u5bf9\u8c61<\/strong><\/div>\nheader\u548cheaderValues\u5bf9\u8c61\u7528\u6765\u8bbf\u95ee\u4fe1\u606f\u5934\uff0c\u901a\u8fc7\u4f7f\u7528 request.getHeader\u65b9\u6cd5\u548crequest.getHeaders\u65b9\u6cd5\u3002<\/p>\n \u4e3e\u4f8b\u6765\u8bf4\uff0c\u8981\u8bbf\u95ee\u4e00\u4e2a\u540d\u4e3auser-agent\u7684\u4fe1\u606f\u5934\uff0c\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\u8868\u8fbe\u5f0f\uff1a${header.user-agent}\uff0c\u6216\u8005${header[\"user-agent\"]}\u3002<\/p>\n \u63a5\u4e0b\u6765\u7684\u4f8b\u5b50\u8868\u660e\u4e86\u5982\u4f55\u8bbf\u95eeuser-agent\u4fe1\u606f\u5934\uff1a<\/p>\n <%@<\/span> page <\/span>import<\/span>=<\/span>\"java.io.*,java.util.*\"<\/span> %>\r\n<\/span><%<\/span>\r\n <\/span>String<\/span> title <\/span>=<\/span> <\/span>\"User Agent Example\"<\/span>;<\/span>\r\n%>\r\n<\/span><html><\/span>\r\n<\/span><head><\/span>\r\n<\/span><title><\/span><%<\/span> <\/span>out<\/span>.<\/span>print<\/span>(<\/span>title<\/span>);<\/span> %><\/span><\/title><\/span>\r\n<\/span><\/head><\/span>\r\n<\/span><body><\/span>\r\n<\/span><center><\/span>\r\n<\/span><h1><\/span><%<\/span> <\/span>out<\/span>.<\/span>print<\/span>(<\/span>title<\/span>);<\/span> %><\/span><\/h1><\/span>\r\n<\/span><\/center><\/span>\r\n<\/span><div<\/span> <\/span>align<\/span>=<\/span>\"center\"<\/span>><\/span>\r\n<\/span><p><\/span>${header[\"user-agent\"]}<\/span><\/p><\/span>\r\n<\/span><\/div><\/span>\r\n<\/span><\/body><\/span>\r\n<\/span><\/html><\/span><\/pre>\n\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a \n \nheader\u5bf9\u8c61\u8fd4\u56de\u5355\u4e00\u503c\uff0c\u800cheaderValues\u5219\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<\/taglib><\/jsp:text><\/jsp:setproperty><\/p>\n","protected":false},"excerpt":{"rendered":" \u5178\u578b\u7684\uff0c\u5f53\u60a8\u9700\u8981\u5728JSP\u6807\u7b7e\u4e2d\u6307\u5b9a\u4e00\u4e2a\u5c5e\u6027\u503c\u65f6\uff0c\u53ea\u9700\u8981\u7b80\u5355\u5730\u4f7f\u7528\u5b57\u7b26\u4e32\u5373\u53ef\uff1a <jsp:setPrope […]<\/p>\n","protected":false},"author":1481,"featured_media":224828,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-224819","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1481"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=224819"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224819\/revisions"}],"predecessor-version":[{"id":224840,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224819\/revisions\/224840"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/224828"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=224819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=224819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=224819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} | | |