Generally, start a tomcat service on your development machine, and then open the browser on your computer. By default, enter http: // localhost: 8080/can be used to access Tomcat's home page. If we want to access Tomcat on the android simulator, can we? The answer is yes, but the access URL will change. Why? Continue.
In general Java WebProgramDuring development, we usually use localhost or 127.0.0.1 to access the Web service of the local machine. However, if we use the same address in the android simulator, the android simulator cannot access our services normally. Why? We can understand that the underlying layer of Android is Linux kernel, and Android itself is an operating system. Therefore, at this time, the input localhost or 127.0.0.1 in the simulator browser represents the android simulator (Android Virtual Machine) instead of your computer. Do you understand? This is why "Web" is reported when you use localhost in the simulator.
Page not available.
How can we access web applications on a local computer? In Android, the address of our local computer is mapped to 10.0.2.2. Therefore, you only need to replace the original localhost or 127.0.0.1 with 10.0.2.2, then you can access the Web Resources on the local computer on the simulator.
Next we will start Tomcat on the computer, run the android simulator, open the browser on the simulator, and then access: http: // 10.0.2.2: 8888 have you seen the cute tomcat cat? See. (Note: on my computer, the Tomcat service uses port 8888. The default value is 8080)
Figure:
Trial, very useful. O (distinct _ distinct) O ~ Haha