===========================学习tomcat的点滴记录=============================================================================
系统重装后,配置好jdk和tomcat环境变量,把项目test1复制到重装的tomcat的webapps下,tomcat能够运行。
进http://localhost:8080/manager/html,打开test1,出来404报错页面。
针对本机出现的问题最后解决方法:test1项目里面没有index.html这样的默认页面。加入index.html后,可以正常打开。
我要求的是没有index.html,可以在http://localhost:8080里面点test1,出来test1里面的目录。
如是在conf文件里的web.xml进行修改:
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
listings的值默认为false,设置为true,就行显示目录。
============================过程记录=======================================
查看logs,发现提示为:Tomcat Native library是1.1.1,要求1.1.8,于是网上下了tcnative-1.dll的1.1.8版本,放到bin目录下面。
tomcat运行没有错误了。
可还是报404错误。http://localhost:8080/能够打开,发现除了本身root项目能运行,只有docs这个项目能够打开。
而这两个项目有个共同点就是都有index.html。于是给test1加入默认页index.html(默认主页可以在conf/web.xml里面修改welcome-file-list),test1可以运行。
因为我的test1项目里面是测试用,有多个测试例子,所以不希望每次从主页跳,之前是直接能目录显示test1里面的文件。
看conf文件夹的web.xml的welcome-file-list上面的注释发现:
<!-- ==================== Default Welcome File List ===================== -->
<!-- When a request URI refers to a directory, the default servlet looks -->
<!-- for a "welcome file" within that directory and, if present, -->
<!-- to the corresponding resource URI for display. If no welcome file -->
<!-- is present, the default servlet either serves a directory listing, -->
<!-- or returns a 404 status, depending on how it is configured. -->
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure that you include any of the default values that -->
<!-- you wish to include. -->
大意是默认找welcom file,如果找不到,就返回目录或404错误,返回什么取决于设置。
在网上查了下设置目录为listings这个参数,于是找到web.xml里面的servlet下,修改listings的值为true(默认为false)。结果成功。