100分!在tomcat5.0上发布应用,一定要放在webapp下面吗,context.xml在哪个文件里配置?

tednugent 2005-03-30 01:58:36
以前用4。0时只要在server.xml里改一下配置就可以了,现在用5。0不知怎么配了,我的app不放在webapps下面,tomcat怎么找到我的目录!?
...全文
389 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞行的兔子 2005-03-31
  • 打赏
  • 举报
回复
楼上的楼上,为什么盗用我的发言不著名出处!
侵权了,知道么?呵呵
怎么总是有人用我的发言呢?
vulcan_1982 2005-03-31
  • 打赏
  • 举报
回复
为什么我的catalina_home\conf\下有个Catalina,在其下面才有localhost,怎么回事?
数据娃掘 2005-03-31
  • 打赏
  • 举报
回复
5.0及以后版本也可以单独写一个以.xml为后缀的文件,在其中加入
<Context path="/math"
docBase="C:\eclipse\workspace\math site\math" debug="0" reloadable="true"
crossContext="true">
</Context>
然后保存在catalina_home\conf\localhost下就可以了
Saro 2005-03-30
  • 打赏
  • 举报
回复
如果你的Servlet仅仅只为初始化环境的化,
<servlet-mapping />不需要.
Saro 2005-03-30
  • 打赏
  • 举报
回复
嗯,注意楼上的
<load-on-startup>1</load-on-startup>
chenxb1980 2005-03-30
  • 打赏
  • 举报
回复
web.xml配置servlet

<servlet>
<servlet-name>AServlet</servlet-name>
<servlet-class>org.chen.AServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AServlet</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
mysyche 2005-03-30
  • 打赏
  • 举报
回复
to up this is right
tednugent 2005-03-30
  • 打赏
  • 举报
回复
我的连接池是写在代码里的,不需要配置的。
现在的问题是启动的时候要直接加载一个servlet
yunqing1028 2005-03-30
  • 打赏
  • 举报
回复
up
飞行的兔子 2005-03-30
  • 打赏
  • 举报
回复
你如果配置连接池的话,既要在server.xml中配置,也要在web.xml中配置,这些你仔细配置过几次就知道个元素的意思了!看看tomcat-docs
tednugent 2005-03-30
  • 打赏
  • 举报
回复
楼上那样配置不好,最好是在web.xml中进行配置,把代码copy到哪都能运行,有谁知道web.xml中参数的意思?
飞行的兔子 2005-03-30
  • 打赏
  • 举报
回复
初始化数据库啊,你是否想用连接池,如果这样,你可以在catalina_home\conf\localhost下写个.xml文件(5.0以后),或者在server.xml中加入:
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>zhutouzip</value>
</parameter>
<parameter>
<name>password</name>
<value>12388321</value>
</parameter>

<!-- Class name for the old mm.mysql JDBC driver - uncomment this entry and comment next
if you want to use this driver - we recommend using Connector/J though
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
-->

<!-- Class name for the official MySQL Connector/J driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>

<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mywebdata?autoReconnect=true</value>
</parameter>
</ResourceParams>
然后在你的项目下WEB-INF\下的web.xml中对应加入:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
这样在初始启动时就将数据库帮定到tomcat的容器环境当中了!
tednugent 2005-03-30
  • 打赏
  • 举报
回复
在tomcat启动的时候怎么设置才能让它自动的进行一些初始化,比如初始化数据库等等
jinsfree 2005-03-30
  • 打赏
  • 举报
回复
楼上的正解!
飞行的兔子 2005-03-30
  • 打赏
  • 举报
回复
5.0及以后版本也可以单独写一个以.xml为后缀的文件,在其中加入
<Context path="/math" docBase="C:\eclipse\workspace\math site\math" debug="0" reloadable="true" crossContext="true">
</Context>
然后保存在catalina_home\conf\localhost下就可以了!
huguangwu 2005-03-30
  • 打赏
  • 举报
回复
正如楼上所说,补充的是:
1 楼上设的是虚拟目录
2 server.xml在tomcat的安装目录的conf目录下
waituy 2005-03-30
  • 打赏
  • 举报
回复
不一定在webapps下面,只要在server.xml 中配置一下就行了!
我估计和4.0一样的
<Context path="/math" docBase="C:\eclipse\workspace\math site\math" debug="0" reloadable="true" crossContext="true">
</Context>

81,095

社区成员

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

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