我有一个名为index.html
的文件,它直接放在WebContent
内,所有脚本文件也在正确的位置。
servlet看起来像这样:
public class CreateService extends HttpServlet {
private static final long serialVersionUID = 1L;
public CreateService() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
//calling html file instead of jsp
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String gisuniqkey=request.getParameter("gisuniqkey");
RequestDispatcher reqDispatcher =
getServletConfig().getServletContext()
.getRequestDispatcher("/index.html");
reqDispatcher.forward(request,response);
}
}
当我尝试在服务器中加载url时,说找不到资源。这是我得到的错误:
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false],
isDirectory: [false], canRead: [false]
org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property
'source' to 'org.eclipse.jst.jee.server:TestProject' did not find a matching property.
PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8180"]
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1481 ms
org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8180"]
org.apache.catalina.startup.Catalina start
INFO: Server startup in 2767 ms
文件夹结构如下所示:
.:
assets images META-INF test.jsp
CreateScenario.jsp index.html ms.jsp UpdateScenario.jsp
cs.jsp index.jsp multipleDisplay.jsp WEB-INF
css js objtype.json
DisplayScenario.jsp JsonData Scenario.json
EditScenario.jsp jsonscenario scripts
./scripts:
gmaps_createScenario.js gmaps_drawPolygon.js info.js maploader.js
gmaps_drawLine.js gmaps_events.js lib
gmaps_drawMarker.js gmaps.js main.js
./scripts/lib:
backbone.min.js jquery.min.js plugins require.js underscore.min.js
./scripts/lib/plugins:
async.js font.js image.js mdown.js propertyParser.js
depend.js goog.js json.js noext.js
这是MainService
,我相信这会重定向到CreateService
:
RequestDispatcher reqDispatcher = getServletConfig().getServletContext().getRequestDispatcher("/CreateService");
reqDispatcher.forward(request,response);
当我尝试调用url时,会抛出以下错误:
Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the
server requires more time, try increasing the timeout in the server editor.
答案 0 :(得分:0)
因此,您要拨打http://localhost:8180/GisProject/MainService?
,根据您的MainService
调用web.xml
课程。不过,您在此处显示的是CreateService
,如果您拨打http://localhost:8180/GisProject/CreateService
,系统会调用该index.html
。
如果你想要的是在调用http://localhost:8180/GisProject/MainService
时显示MainService
,那么你必须将实现移到{{1}}类。