将h2console集成到Web项目中

时间:2013-09-03 06:43:40

标签: java jsp servlets jboss7.x h2

我想将H2控制台集成到我的Web应用程序中,我尝试以下代码: 在web.xml文件中:

    <?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  
  <display-name>h2Wrapper</display-name>  
  <servlet>  
    <servlet-name>H2Console</servlet-name>  
    <servlet-class>org.h2.server.web.WebServlet</servlet-class>  

    <init-param>  
      <param-name>webAllowOthers</param-name>  
      <param-value>true</param-value>  
    </init-param>  
    <load-on-startup>1</load-on-startup>  
  </servlet>  
  <servlet-mapping>  
    <servlet-name>H2Console</servlet-name>  
    <url-pattern>/h2/*</url-pattern>  
  </servlet-mapping>  
  <welcome-file-list>  
    <welcome-file>index.html</welcome-file>  
    <welcome-file>index.htm</welcome-file>  
    <welcome-file>index.jsp</welcome-file>  
    <welcome-file>default.html</welcome-file>  
    <welcome-file>default.htm</welcome-file>  
    <welcome-file>default.jsp</welcome-file>  
  </welcome-file-list>  
</web-app>  

并在index.jsp文件中:

 <body>
  <form method="POST" action="/h2/console/login.jsp">
<input type="hidden" name="user" value="sa" />
<input type="hidden" name="password" value="" />
<input type="hidden" name="driver" value="org.h2.Driver" />
<input type="hidden" name="language" value="en" />
<input type="hidden" name="setting" value="Generic H2 (Embedded)" />
<input type="hidden" name="name" value="Generic H2 (Embedded)" />
<input type="hidden" name="url" value="jdbc:h2:C:\path\to\my\h2\db" />
<input type="submit" value="H2"/>
</form>
  </body>

但它给了我这个错误: 请求的资源(/h2/console/login.jsp)不可用。

你可以帮帮我吗? 应该怎么做? 谢谢......

0 个答案:

没有答案