【发布时间】:2017-01-08 09:39:04
【问题描述】:
下面是我的 index.html 和 action.jsp 代码 当我将 index.html 中的值提交给 action.jsp 而不是在 action.jsp 中获取 out.println 的输出时,我得到了完整的 action.jsp 作为我的输出。
告知问题是什么以及如何纠正它还告知目录结构是否正确,即;所有文件都放置在通常应该放置或不放置的位置
<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>
【问题讨论】:
-
你能告诉我们你在控制台收到了什么消息吗!!
-
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|信息:在 [/Website] 加载应用程序 [网站] 2017-01-09T13:00:09.175+0530|信息:网站成功部署时间为 558 毫秒。我还更新了我的目录结构,请查看并告知所有文件(例如:.jsp、.html)是否都在它们应该在的位置。