以下是我的index.html和action.jsp代碼 當我將index.html中的值提交到action.jsp而不是在action.jsp中獲取out.println的輸出時我得到完整的action.jsp作爲我的輸出。 使用JSP和Hibernate的Web應用程序的問題
建議是什麼問題,以及如何糾正它也建議目錄結構是否正確,即;所有的文件都放在他們通常應該放置或不
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="action.jsp" method="post">
Name <input type="text" name = "name"> <br>
Password <input type="password" name="password"> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
// Below is action.jsp
<%@page import="p1.NewHibernateUtil"%>
<%@page import="org.hibernate.Transaction"%>
<%@page import="p1.User"%>
<%@page import="org.hibernate.Session"%>
<%@page import="org.hibernate.SessionFactory"%>
<%@page import="org.hibernate.cfg.Configuration"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
out.println("In scriplet tag");
Configuration cfg = new Configuration();
out.println("Configuration object created");
cfg.configure("hibernate.cfg.xml");
out.println("Configured");
// SessionFactory sf = NewHibernateUtil.getSessionFactory();
// out.println("SessionFactory created");
// Session ses = sf.openSession();
// Transaction t = ses.beginTransaction();
// String n = request.getParameter("name");
// String p = request.getParameter("password");
//
// out.println("Welcome " + n);
// User u1 = new User(n, p);
// ses.save(u1);
// t.commit();
// ses.close();
// out.println("Data inserted successfully");
%>
</body>
</html>
你能告訴我們你這是在控制檯上獲得的消息! – PacMan
2017-01-09T13:00:08.633 + 0530 |信息:訪問未訪問引用 2017-01-09T13:00:08.887 + 0530 |信息:訪問未訪問引用 2017-01-09T13:00:08.893 + 0530 |信息:訪問未訪問的參考文獻 2017-01-09T13:00:09.139 + 0530 |信息:正在加載應用程序[網站] [/網站] 2017-01-09T13:00:09.175 + 0530 |信息:網站已成功部署在558毫秒。 另外我有更新我的目錄結構的問題,請看看,並建議如果所有的文件(如:.jsp,.html)是他們應該在哪裏。 – krishna