Advertisement
Guest User

Untitled

a guest
Jul 21st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package com.ecommerce.demo;
  2.  
  3. import javax.persistence.*;
  4.  
  5. @Entity
  6. @Table(name="USER")
  7. public class User {
  8. @Id
  9. private String userName;
  10. private String userPassword;
  11.  
  12. public String getUserName() {
  13. return userName;
  14. }
  15. public void setUserName(String userName) {
  16. this.userName = userName;
  17. }
  18. public String getUserPassword() {
  19. return userPassword;
  20. }
  21. public void setUserPassword(String userPassword) {
  22. this.userPassword = userPassword;
  23. }
  24.  
  25.  
  26. }
  27.  
  28. package com.ecommerce.controller;
  29.  
  30. import java.io.IOException;
  31. import java.util.List;
  32. import javax.websocket.Session;
  33.  
  34. import org.hibernate.*;
  35. import org.hibernate.cfg.*;
  36. import org.json.JSONArray;
  37. import org.springframework.stereotype.Controller;
  38. import org.springframework.ui.Model;
  39. import org.springframework.validation.BindingResult;
  40. import org.springframework.web.bind.annotation.ModelAttribute;
  41. import org.springframework.web.bind.annotation.RequestMapping;
  42. import org.springframework.web.bind.annotation.RequestMethod;
  43. import org.springframework.web.servlet.ModelAndView;
  44.  
  45. import com.ecommerce.demo.User;
  46.  
  47. @Controller
  48. @RequestMapping(value="mainPageController")
  49. public class MainPageController {
  50.  
  51. @RequestMapping(value="/mainPage.html")
  52. public ModelAndView getLogInForm(@ModelAttribute("user") User userInput, BindingResult result) throws IOException {
  53.  
  54. List<User> userDatabase = null;
  55.  
  56. userDatabase = session.createQuery("from User").list();
  57.  
  58. session.beginTransaction();
  59. session.close();
  60.  
  61. ModelAndView model = new ModelAndView("MainPage");
  62. model.addObject("userNameAndPasswordList", userDatabase);
  63.  
  64. return model;
  65. }
  66.  
  67. }
  68.  
  69. <%@ page import="com.ecommerce.demo.User" %>
  70.  
  71. <%
  72. Usinf java code(i.e for loop)
  73. I need to print all userName and userPassword of user class here.
  74. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement