{"id":2268,"date":"2023-08-07T18:39:33","date_gmt":"2023-08-07T10:39:33","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=2268"},"modified":"2023-08-07T18:39:33","modified_gmt":"2023-08-07T10:39:33","slug":"jsp%e7%bd%91%e9%a1%b5%e7%94%9f%e6%88%90app%e6%8e%a8%e8%8d%90%e4%bd%bf%e7%94%a8%e4%b8%80%e9%97%a8app%e5%bc%80%e5%8f%91%e5%b9%b3%e5%8f%b0","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/2268\/","title":{"rendered":"jsp\u7f51\u9875\u751f\u6210app\u63a8\u8350\u4f7f\u7528\u4e00\u95e8APP\u5f00\u53d1\u5e73\u53f0"},"content":{"rendered":"

\u6807\u9898\uff1aJSP\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4e0e\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n

\u4ecb\u7ecd\uff1a<\/p>\n

\u968f\u7740\u79fb\u52a8\u4e92\u8054\u7f51\u7684\u8fc5\u901f\u53d1\u5c55\uff0c\u5c06\u7f51\u9875\u5e94\u7528\u8f6c\u5316\u6210\u624b\u673aAPP\u6210\u4e3a\u4e86\u4e00\u79cd\u8d8b\u52bf\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528JSP\uff08Java Server Pages\uff09\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u53ca\u76f8\u5173\u65b9\u6cd5\u3002\u8fd9\u5bf9\u4e8e\u5165\u95e8\u7ea7\u4eba\u5458\u5c24\u5176\u5177\u6709\u53c2\u8003\u4ef7\u503c\u3002<\/p>\n

\u4e00\u3001JSP\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406<\/p>\n

\u5728\u5c06JSP\u7f51\u9875\u751f\u6210APP\u4e4b\u524d\uff0c\u6211\u4eec\u9996\u5148\u8981\u4e86\u89e3\u8fd9\u4e00\u8fc7\u7a0b\u7684\u539f\u7406\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u5c06JSP\u7f51\u9875\u5c01\u88c5\u5230\u4e00\u4e2a\u79fb\u52a8APP\u4e2d\uff0c\u4f7f\u5176\u5177\u5907\u7c7b\u4f3c\u4e8e\u539f\u751fAPP\u7684\u7528\u6237\u4f53\u9a8c\u3002\u8fd9\u79cd\u5b9e\u73b0\u65b9\u5f0f\u901a\u5e38\u79f0\u4e3a\u201cWebview\u201d\u3002<\/p>\n

Webview\u662f\u79fb\u52a8APP\u4e2d\u7684\u4e00\u79cd\u7ec4\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5c06\u7f51\u9875\u52a0\u8f7d\u5230APP\u5185\u90e8\u8fdb\u884c\u5c55\u793a\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cJSP\u7f51\u9875\u4f5c\u4e3a\u670d\u52a1\u5668\u7aef\u7684\u4e00\u79cd\u6280\u672f\uff0c\u7ecf\u7531Webhtml5\u7f51\u7ad9\u751f\u6210app<\/a>view\u52a0\u8f7d\u540e\u5448\u73b0\u7ed9\u7528\u6237\u3002<\/p>\n

\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8eWebview\u4f9d\u8d56\u4e8e\u8bbe\u5907\u4e0a\u7684\u6d4f\u89c8\u5668\u5f15\u64ce\uff0c\u56e0\u6b64\u4e0d\u540c\u8bbe\u5907\u4e4b\u95f4\u53ef\u80fd\u5b58\u5728\u5dcb\u5f02\u6027\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u60a8\u7684JSP\u7f51\u9875\u5e94\u8be5\u5728\u5404\u79cd\u8bbe\u5907\u4e0a\u8fdb\u884c\u5e7f\u6cdb\u7684\u6d4b\u8bd5\u3002<\/p>\n

\u4e8c\u3001JSP\u7f51\u9875\u751f\u6210APP\u7684\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06JSP\u7f51\u9875\u751f\u6210\u4e3aAPP\u3002\u5728\u6b64\uff0c\u6211\u4eec\u4ee5\u521b\u5efaAndroid APP\u4e3a\u4f8b\u3002<\/p>\n

1. \u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n

a. \u4e0b\u8f7d\u5e76\u5b89\u88c5Android Studio\uff1ahttps:\/\/developer.android.com\/studio<\/p>\n

b. \u5b89\u88c5Java\u5f00\u53d1\u73af\u5883\uff08JDK\uff09\uff1ahttps:\/\/www.oracle.com\/java\/technologies\/javase-downloads.html<\/p>\n

c. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Android Studio\u9879\u76ee\u5e76\u9009\u62e9\u9002\u5f53\u7684\u9009\u9879\u3002<\/p>\n

2. \u6dfb\u52a0Webview\u7ec4\u4ef6\uff1a<\/p>\n

a. \u5728\u9879\u76ee\u7684\u4e3b\u5e03\u5c40\u6587\u4ef6\uff08activity_main.xml\uff09\u4e2d\uff0c\u6dfb\u52a0Webview\u7ec4\u4ef6\u3002<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/webView”<\/p>\n

android:layout_width=”match_parent”<\/p>\n

android:layout_height=”match_parent”\/><\/p>\n

“`<\/p>\n

b. \u5728MainActivity.java\u6587\u4ef6\u4e2d\uff0c\u521d\u59cb\u5316Webview\u5e76\u914d\u7f6e\u76f8\u5173\u53c2\u6570\u3002<\/p>\n

“`java<\/p>\n

\/\/ \u5bfc\u5165\u6240\u9700\u5e93<\/p>\n

import android.webkit.WebView;<\/p>\n

import android.webkit.WebViewClient;<\/p>\n

\/\/ \u5728onCreate\u65b9\u6cd5\u4e2d\u521d\u59cb\u5316Webview\u7ec4\u4ef6<\/p>\n

WebView webView = findViewById(R.id.webView);<\/p>\n

\/\/ \u542f\u7528Javascript<\/p>\n

webView.getSettings().setJavaScriptEnabled(true);<\/p>\n

\/\/ \u4f7f\u7528Webview\u6253\u5f00\u7f51\u9875\uff0c\u800c\u975e\u6d4f\u89c8\u5668<\/p>\n

webView.setWebViewClient(new WebViewClient());<\/p>\n

“`<\/p>\n

3. \u52a0\u8f7dJSP\u7f51\u9875\uff1a<\/p>\n

\u5728\u4e4b\u524d\u914d\u7f6e\u597d\u7684Webview\u4e0a\u52a0\u8f7dJSP\u7f51\u9875\u3002\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230MainActivity.java\u6587\u4ef6\u7684onCreate\u65b9\u6cd5\u4e2d\uff0c\u5373\u53ef\u52a0\u8f7d\u6307\u5b9a\u7684JSP\u7f51\u9875\u3002<\/p>\n

“`jav<\/p>\n

<\/figure>\n<\/p>\n

a<\/p>\n

webView.loadUrl(“http:\/\/your-domain.com\/your-jsp-page.jsp”);<\/p>\n

“`<\/p>\n

4. \u4fee\u6539\u6743\u9650\uff1a<\/p>\n

\u5728AndroidManifest.xml\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u7f51\u7edc\u6743\u9650\uff0c\u4ee5\u4fbfAPP\u80fd\u591f\u8bbf\u95ee\u4e92\u8054\u7f51\u3002<\/p>\n

“`xml<\/p>\n<\/p>\n

“`<\/p>\n

5. \u7f16\u8bd1\u4e0e\u6d4b\u8bd5\uff1a<\/p>\n

a. \u70b9\u51fbAndroid Studio\u4e2d\u7684\u201cBuild\u201d\u6309\u94ae\uff0c\u5f00\u59cb\u7f16\u8bd1\u9879\u76ee\u3002<\/p>\n

b. \u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u5b89\u88c5\u5230\u76f8\u5e94\u7684\u8bbe\u5907\u4e0a\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n

c. \u82e5\u8981\u53d1\u5e03APP\uff0c\u8bf7\u9075\u5faaAndr\u5f71\u89c6\u7f51\u7ad9app\u5728\u7ebf\u751f\u6210<\/a>oid APP\u53d1\u5e03\u6307\u5357\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5c06JSP\u7f51\u9875\u751f\u6210\u4e3aAPP\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e3a\u4e86\u83b7\u5f97\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u9488\u5bf9\u79fb\u52a8\u7aef\u8bbe\u5907\u5bf9JSP\u7f51\u9875\u7684\u754c\u9762\u5e03\u5c40\u8fdb\u884c\u4f18\u5316\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u539f\u751f\u4ee3\u7801\u4e0eJSP\u7f51\u9875\u5b9e\u73b0\u6df7\u5408\u5f00\u53d1\uff0c\u63d0\u5347\u6574\u4f53APP\u7684\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6807\u9898\uff1aJSP\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4e0e\u8be6\u7ec6\u4ecb\u7ecd\u4ecb\u7ecd\uff1a\u968f\u7740\u79fb\u52a8\u4e92\u8054\u7f51\u7684\u8fc5\u901f\u53d1\u5c55\uff0c\u5c06\u7f51\u9875\u5e94\u7528\u8f6c\u5316\u6210\u624b\u673aAPP\u6210\u4e3a\u4e86\u4e00\u79cd\u8d8b\u52bf\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528JSP\uff08Java Server Pages\uff09\u7f51\u9875\u751f\u6210APP\u7684<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[160,4775,16,4776,149],"topic":[],"class_list":{"0":"post-2268","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkf","7":"tag-160","8":"tag-app","9":"tag-16","11":"tag-149"},"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=2268"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2268\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=2268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=2268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=2268"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=2268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}