【问题标题】:Issue with web application using JSP and Hibernate使用 JSP 和 Hibernate 的 Web 应用程序出现问题
【发布时间】: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)是否都在它们应该在的位置。

标签: html hibernate jsp


【解决方案1】:

根据我的假设,您正在运行给定的示例而不使用 Web 服务器。您将需要 Web 服务器来运行给定的代码。

考虑使用网络服务器(例如 Tomcat http://tomcat.apache.org/tomcat-8.0-doc/index.html

【讨论】:

  • 我正在使用 glassfish 服务器,我可以在部署的应用程序中看到 Glassfish 管理中的应用程序(项目)。我还更新了我的目录结构,请查看并告知所有文件(例如:.jsp、.html)是否在它们应该在的位置
猜你喜欢
  • 2022-10-05
  • 1970-01-01
  • 1970-01-01
  • 2020-01-22
  • 1970-01-01
  • 2014-10-11
  • 1970-01-01
  • 2011-10-04
  • 1970-01-01
相关资源
最近更新 更多