首页 > 代码库 > Myeclipse下的Tomcat映射问题

Myeclipse下的Tomcat映射问题

  这个问题真的很头疼啊。

环境是:

Myeclipse2015

tomcat 8(使用Myeclipse默认导入的配置)

问题呢:

  在Myeclipse下创建一个web project,如果是不创建默认web.xml,就可以进入index页面。

  如果默认创建了web.xml文件,就会出现404错误。

  然而,最头疼的是,我创建了一个EasyUI的测试project,页面就两个,index.jsp和main.jsp,

 

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 <!DOCTYPE html> 7 <html> 8   <head> 9       <meta charset="UTF-8">10     <title>Basic Combo - jQuery EasyUI Demo</title>11     <link rel="stylesheet" type="text/css" href="http://www.mamicode.com/lib/themes/default/easyui.css">12     <link rel="stylesheet" type="text/css" href="http://www.mamicode.com/lib/themes/icon.css">13     <script type="text/javascript" src="http://www.mamicode.com/lib/jquery.min.js"></script>14     <script type="text/javascript" src="http://www.mamicode.com/lib/jquery.easyui.min.js"></script>15   </head>16   <body class="easyui-layout">17     <div data-options="region:‘north‘,title:‘North Title‘,split:true" style="height:100px;"></div>18     <div data-options="region:‘south‘,title:‘South Title‘,split:true" style="height:100px;"></div>19     <div data-options="region:‘east‘,title:‘East‘,split:true" style="width:100px;"></div>20     <div data-options="region:‘west‘,title:‘West‘,split:true" style="width:100px;"></div>21     <div data-options="region:‘center‘,title:‘center title‘" style="padding:5px;background:#eee;"></div>22    </body>23 </html>

  在Myeclipse编辑器的模式下,没有任何报错,js文件引用也是没有问题。

  然后,在导入到Tomcat下运行时,问题来了,提示easyui.css、icon.css、jquery.min.js、jquery.easyui.min.js 404错误

  看错误下的地址是http://localhost:8080/lib/themes/default/easyui.css

  如果是正确的路径的话,lib目录在 %Tomcat_Path%/webapps/webte/lib/themes/default/easyui.css

  暂时的解决办法就是在%Tomcat_Path%/webapps/下,把lib文件夹复制一份到这里,然后,页面就显示正常了

  问题探究,在Myeclipse下,启动tomcat,在Console下也灭有提示明显的错误,也没有修改过Myeclipse的配置,然而,就是不能用。感觉一下子没了头绪

十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Server version:        Apache Tomcat/8.0.38十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Server built:          Oct 6 2016 20:51:55 UTC十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Server number:         8.0.38.0十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: OS Name:               Windows 8十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: OS Version:            6.2十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Architecture:          amd64十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Java Home:             E:\MyEclipse\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: JVM Version:           1.7.0_45-b18十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: JVM Vendor:            Oracle Corporation十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: CATALINA_BASE:         E:\Tomcat十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: CATALINA_HOME:         E:\Tomcat十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Xmx1024M十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Xms512M十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -XX:MaxPermSize=256m十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Dcatalina.base=E:\Tomcat十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Dcatalina.home=E:\Tomcat十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Dwtp.deploy=E:\Tomcat\webapps十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Djava.endorsed.dirs=E:\Tomcat\endorsed十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Command line argument: -Dfile.encoding=UTF-8十月 15, 2016 7:00:48 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\MyEclipse\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;"D:\MySQL\MySQL Server 5.7\bin";C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\MuNineyi\AppData\Local\Microsoft\WindowsApps;.十月 15, 2016 7:00:48 下午 org.apache.coyote.AbstractProtocol init信息: Initializing ProtocolHandler ["http-nio-8080"]十月 15, 2016 7:00:48 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector信息: Using a shared selector for servlet write/read十月 15, 2016 7:00:48 下午 org.apache.coyote.AbstractProtocol init信息: Initializing ProtocolHandler ["ajp-nio-8009"]十月 15, 2016 7:00:48 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector信息: Using a shared selector for servlet write/read十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.Catalina load信息: Initialization processed in 862 ms十月 15, 2016 7:00:48 下午 org.apache.catalina.core.StandardService startInternal信息: Starting service Catalina十月 15, 2016 7:00:48 下午 org.apache.catalina.core.StandardEngine startInternal信息: Starting Servlet Engine: Apache Tomcat/8.0.38十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory E:\Tomcat\webapps\lib1十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deployment of web application directory E:\Tomcat\webapps\lib1 has finished in 487 ms十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory E:\Tomcat\webapps\ROOT十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deployment of web application directory E:\Tomcat\webapps\ROOT has finished in 24 ms十月 15, 2016 7:00:48 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory E:\Tomcat\webapps\webte十月 15, 2016 7:00:49 下午 org.apache.jasper.servlet.TldScanner scanJars信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.十月 15, 2016 7:00:49 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deployment of web application directory E:\Tomcat\webapps\webte has finished in 406 ms十月 15, 2016 7:00:49 下午 org.apache.coyote.AbstractProtocol start信息: Starting ProtocolHandler ["http-nio-8080"]十月 15, 2016 7:00:49 下午 org.apache.coyote.AbstractProtocol start信息: Starting ProtocolHandler ["ajp-nio-8009"]十月 15, 2016 7:00:49 下午 org.apache.catalina.startup.Catalina start信息: Server startup in 1008 ms

 

问题原因:

在main.jsp中

<head>

  <base href="http://www.mamicode.com/">

</head>

就少了一句这个。。。

Myeclipse下的Tomcat映射问题