Topic: Tomcat下的Servlet测试 |
Print this page |
1.Tomcat下的Servlet测试 | Copy to clipboard |
Posted by: Antelope Posted on: 2004-02-19 11:05 我在Tomcat的webapps建了个eshop的web应用: webapps --eshop ----index.jsp ----WEB-INF ------web.xml --------classes ----------shopping ------------shoppingServlet.class web.xml的内容是: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>My Web Application</display-name> <description> A application for test. </description> <servlet> <servlet-name>ShoppingServlet</servlet-name> <display-name>ShoppingServlet</display-name> <description>A test Servlet</description> <servlet-class>shopping.ShoppingServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ShoppingServlet</servlet-name> <url-pattern>/ShoppingServlet</url-pattern> </servlet-mapping> </web-app> 然后我在浏览器里面输入:http://127.0.0.1:8080/eshop/ShoppingServlet 这个servlet是能正确显示的。 而后我把整个eshop目录剪切到webapps\examples下面,重启Tomcat。 在浏览器里面输入http://127.0.0.1:8080/examples/eshop/ShoppingServlet 说找不到这个servlet。 不知道什么原因? |
2.Re:Tomcat下的Serlet测试 [Re: Antelope] | Copy to clipboard |
Posted by: Jove Posted on: 2004-02-19 11:24 http://127.0.0.1:8080/examples/eshop/ShoppingServlet Tomcat收到这个请求,会去交给examples这个app来处理 在examples/WEB-INF/web.xml中并没有对ShoppingServlet做servlet-mapping 所以不能处理这个请求 解决方法: 把ShoppingServlet的class或jar文件放到examples/WEB-INF下的classes目录或lib目录 修改examples/WEB-INF/web.xml 添加ShoppingServlet的声明和映射(/eshop/ShoppingServelt) |
3.Re:Tomcat下的Serlet测试 [Re: Antelope] | Copy to clipboard |
Posted by: Antelope Posted on: 2004-02-19 11:41 呵呵,行了。 映射的时候我只写(/ShoppingServlet)好像不行。 我见Tomcat的里面映射的时候都没加目录……不知道啥缘故。 |
4.Re:Tomcat下的Serlet测试 [Re: Antelope] | Copy to clipboard |
Posted by: panjiandong Posted on: 2004-04-15 23:25 几位大哥 我还不会配置你们能把它们发出来吗 谢谢哦 |
5.Re:Tomcat下的Servlet测试 [Re: Antelope] | Copy to clipboard |
Posted by: panjiandong Posted on: 2004-04-19 08:34 我的配置和上面的一样的怎么我运行!start tomcat还有下面的错误 而且是什么错误呢 start tomcat: 严重: Parse Error at line 25 column 11: The content of element type "web-app" mu st match "(icon?,display-name?,description?,distributable?,context-param*,filter *,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappi ng*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,secur ity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*) ". org.xml.sax.SAXParseException: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter- mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welco me-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-const raint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)". at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un known Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown S ource) at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement( Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent Dispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un known Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.commons.digester.Digester.parse(Digester.java:1543) at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextCo nfig.java:282) at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:63 9) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi g.java:243) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:166) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3 567) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase .java:821) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80 7) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep loyer.java:307) at org.apache.catalina.core.StandardHost.install(StandardHost.java:772) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j ava:559) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:401 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:718) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :358) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:166) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 97) at org.apache.catalina.core.StandardServer.start(StandardServer.java:219 0) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) 2004-4-19 20:31:33 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on port 8080 2004-4-19 20:31:33 org.apache.jk.common.ChannelSocket init 信息: JK2: ajp13 listening on /0.0.0.0:8009 2004-4-19 20:31:33 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=10/120 config=C:\Tomcat 4.1\conf\jk2.properties 修改examples/WEB-INF/web.xml 添加ShoppingServlet的声明和映射(/eshop/ShoppingServelt) 在哪一行加都可以吗 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |