当前位置: 代码迷 >> J2EE >> 各位来帮小弟我看看这个servlet的连接有关问题
  详细解决方案

各位来帮小弟我看看这个servlet的连接有关问题

热度:28   发布时间:2016-04-22 00:32:00.0
各位来帮我看看这个servlet的连接问题
大体是这样的 我在给serlet写连接的时候老是提示这个问题 我也解决不了

The target KimiFirstServlet.java cannot be started as a servlet, because the web.xml does not contain a servlet mapping for it.
The target KimiFirstServlet.java cannot be started as an application, because the class KimiFirstServlet does not have a main method.
The target KimiDatabaseSerlet.java cannot be started because it does not exist.


我的数据库是装在我的虚拟机上的 jdeveloper是在本机上 连接的时候我用的也是虚拟机的IP 但是就是不能连接 我也不知道是怎么回事的 劳驾各位给我看看

下面是我的connection代码 各位给指点指点

  try {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@10.10.64.244:1521:ORCL","scott","tiger");
  } catch (Exception e) {
  // TODO: Add catch code
  e.printStackTrace();
  }

------解决方案--------------------
The target KimiFirstServlet.java cannot be started as a servlet, because the web.xml does not contain a servlet mapping for it.
这句话说得很清楚了。web.xml里没有配置servlet mapping

具体配置参考:
XML code
  <servlet>     <servlet-name>AxisServlet</servlet-name>     <display-name>Apache-Axis Servlet</display-name>     <servlet-class>         org.apache.axis.transport.http.AxisServlet     </servlet-class>   </servlet>    <servlet-mapping>     <servlet-name>AxisServlet</servlet-name>     <url-pattern>/servlet/AxisServlet</url-pattern>   </servlet-mapping>
  相关解决方案