Java Web 新手问题,吐血求助各位大侠

whhushuai 2013-08-02 04:28:03
大家好!我是一个刚学习Java web 开发的新手,遇到以下问题困扰了很多天,吐血求助!我安装的Tomcat6.0,安装在了F:盘
并且手工建立了一个web项目,没用整合工具,web项目我放在了E盘,目录结构E:/JavaWebApp/test/WEB-INF,
JavaWebApp/test/WEB-INF/web.xml,JavaWebApp/test/WEB-INF/lib,JavaWebApp/test/WEB-INF/lib/jstl.jar,
JavaWebApp/test/WEB-INF/lib/standard.jar, JSP文件我放在了JavaWebApp/test/目录下面,
结果我一运行就报错如下:



我的jsp文件代码如下:
文件名TestTaglib.jsp
<%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>JSTL核心标签库</title>
</head>
<body>
JSTL核心标签库输出: <br>
<c:out value="Hello! JSP!"/>
</body>
</html>
如果去掉<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>运行就没问题
但是一加上就报错,但是我把这个jsp文件放在tomcat的webapps下的examples下面就可以正常运行
我的web.xml代码如下
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
</web-app>
我的项目WEN-INF下面明明有web.xml,但是tomcat为什么会报错呢?说找不到呢?
为什么去掉<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>一切都正常了呢?
我的lib下面已经复制了jstl.jar和standard.jar两个包,
Tomcat的server.xml文件代码如下:
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->

<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
<Context path="/test/ch01" docBase="E:\JavaWebApp\test\ch01" />
<Context path="/test/ch02" docBase="E:\JavaWebApp\test\ch02" />
<Context path="/test/ch03" docBase="E:\JavaWebApp\test\ch03" />
</Host>
</Engine>
</Service>
</Server>
...全文
293 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
whhushuai 2013-08-02
  • 打赏
  • 举报
回复
11楼帅哥 太谢谢你了! 你说的是正确的! 新手就是容易犯一些低级错误 小女子有礼了! 谢谢!!!
末日哥 2013-08-02
  • 打赏
  • 举报
回复
可能是版本问题 jstl1.0 的声明是:<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core " %> jstl1.1 的声明是:<%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core %>
望_mm 2013-08-02
  • 打赏
  • 举报
回复
你配置文件改一下 <Context path="/test" docBase="E:\JavaWebApp\test" />,这样才是配置工程,ch01,ch02,ch03只是工程下的文件夹,访问文件夹下jsp的时候路径中带着就可以了,你原先配置,tomcat会到你 E:\JavaWebApp\test\ch01下去找WEB-INF下的web.xml等,我想是这样的吧,试试
oh_Maxy 2013-08-02
  • 打赏
  • 举报
回复
你这不是Web工程啊。。 建议用工具建个web工程,对比看看缺了什么。。
whhushuai 2013-08-02
  • 打赏
  • 举报
回复
我的WEB-INF下面确实有web.xml文件啊!
yang463488415 2013-08-02
  • 打赏
  • 举报
回复
你自己看一下,500是自己的语法有问题,别急着求别人。
whhushuai 2013-08-02
  • 打赏
  • 举报
回复

这是我手工布置建立的项目结构
这个放在tomcat webapps下面没有什么问题 但是我就是想手工联系整合整合 解决一下这个问题
chenchenchenliu 2013-08-02
  • 打赏
  • 举报
回复
看了你的错误提示,找不到WEB-INF下的web.xml配置文件。你看看你的文件夹下是否有这个配置文件。
chenchenchenliu 2013-08-02
  • 打赏
  • 举报
回复
给楼主提供一个思路 首先启动好tomcat之后,现在浏览器中输入http://localhost:8080 回车,看看能不能进入tomcat首页,如果可以说明服务器没问题,然后再进行下一步操作。 可以重新建一个web工程,不做任何改动,直接加到tomcat服务中,然后启动服务访问该工程,看是否正常,如果正常,在进行下一步操作。 尝试写自己的东西到工程里面,,需要导入额外的jar包就导入到WebRoot-->WEB-INF-->lib文件夹下 然后在运行工程,这样一步一步来。希望对你有帮助。
Tony_Simon 2013-08-02
  • 打赏
  • 举报
回复
可能原因:你手动整合不全,把整合好的项目,整个方到tomcat中,至少不会再报找不到jstl
S117 2013-08-02
  • 打赏
  • 举报
回复
你项目里有jstl的jar包吗?
ZHOU西口 2013-08-02
  • 打赏
  • 举报
回复
可否把你的整个project的目录结构贴出来?完整的
whhushuai 2013-08-02
  • 打赏
  • 举报
回复
为什么没人回复我 高手们都去哪里了啊!!!!!!!!我哭

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧