编辑tomcat/conf/server.xml文件
在<Context path="/examples" docBase="examples" debug="0"
reloadable="true">
..........
</Context>
的前面或者后面加上
<Context path="/myapp" docBase="你的目录的路径" debug="0" (在这里)
reloadable="true"/>
然后你的目录安排如下
根目录
------+/WEB-INF/(required)
| |
| |----+/classes/(option)
| | |----------*.class
| |
| |----+/lib/(option)
| | |----------*.jar
| |
| +---web.xml(required)
| +---weblogic.xml(option)
|
|
|-----*.html
|-----*.jsp
|-----其他资源,如图片等
在<Context path="/examples" docBase="examples" debug="0"
reloadable="true">
..........
</Context>
的前面或者后面加上
<Context path="/myapp" docBase="你的目录的路径" debug="0" (在这里)
reloadable="true"/>
然后你的目录安排如下
根目录
------+/WEB-INF/(required)
| |
| |----+/classes/(option)
| | |----------*.class
| |
| |----+/lib/(option)
| | |----------*.jar
| |
| +---web.xml(required)
| +---weblogic.xml(option)
|
|
|-----*.html
|-----*.jsp
|-----其他资源,如图片等
在你的项目下面 有一个 defaultroot目录 ,编译完,就是了
在<web-app></web-app>中加入下面的,就可以访问servlet了
<servlet><servlet-name>HelloServlet</servlet-name><servlet-class>HelloServlet</servlet-class></servlet>
<servlet-mapping><servlet-name>HelloServlet</servlet-name><url-pattern>/hello</url-pattern></servlet-mapping>
servlet-class是你的servlet的类的名字
2个servlet-name是一样的
url-pattern是你访问的路径
比如你的目录web访问是http://127.0.0.1/root
servlet 就是http://127.0.0.1/root + url-pattern
你的目录安排如下
根目录
------+/WEB-INF/(required)
| |
| |----+/classes/(option)
| | |----------*.class
| |
| |----+/lib/(option)
| | |----------*.jar
| |
| +---web.xml(required)
|
|-----*.html
|-----*.jsp
|-----其他资源,如图片等