jsp和Hibernate能不能共用?
我在进行一个web开发,想用jsp调用后台hibernate类对数据库操作,但是老是失败,请问怎么回事:
前台jsp页面:
Login.jsp
<%@ page language= "java " import= "java.util.* " pageEncoding= "gb2312 "%>
<%@ page isErrorPage= "True "%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<base href= " <%=basePath%> ">
<title> My JSP 'Login.jsp ' starting page </title>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->
</head>
<%--/Home_Auto_Sys_2/src/Servlet.Login--%>
<body> Welcome to use HAS system:
<FORM action= "Login_ok.jsp " method= "post ">
<P align= "center ">
用户ID : <INPUT type= "text " name= "UserID "> </P>
<P align= "center ">
用户名称: <INPUT type= "text " name= "UserName "> </P>
<P align= "center "> 用户密码: <INPUT type= "password " name= "Password "> </P>
<P align= "center "> <INPUT type= "Submit " name= "Submit " value= "提交 " />
<INPUT type= "Reset " name= "Reset " value= "重置 "/> </P>
</FORM>
</body>
</html>
[解决办法]
可以公用,但是你配置好xml文件及相关映射hbm。xml
[解决办法]
可以,不过要告诉搂住:hibernate虽然存取数据速度比较快,但是它比较呆板,不如jdbc来的灵活,这点请搂住注意。一般来说都是hibernate和jdbc结合用的,就是同时保留两种数据存取方式的接口,根据情况选择使用。