Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1" ?>
  2. <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
  3. <jsp:directive.page contentType="text/html; charset=ISO-8859-1"
  4. pageEncoding="ISO-8859-1" session="false"/>
  5. <jsp:output doctype-root-element="html"
  6. doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  7. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  8. omit-xml-declaration="true" />
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <title>Welcome</title>
  12. </head>
  13. <body>
  14. <a href="welcome">Welcome Guest</a>
  15. </body>
  16. </html>
  17. </jsp:root>
  18.  
  19. package java4s;
  20.  
  21. import org.springframework.stereotype.Controller;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RequestMethod;
  24. import org.springframework.web.servlet.ModelAndView;
  25. import org.springframework.ui.Model;
  26. import org.springframework.web.bind.annotation.ModelAttribute;
  27. import org.springframework.web.servlet.ModelAndView;
  28. import org.springframework.ui.ModelMap;
  29. import org.springframework.format.annotation.DateTimeFormat;
  30. import java.util.ArrayList;
  31. import java.util.List;
  32. import java.text.SimpleDateFormat;
  33. import java.util.Date;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35.  
  36. import java4s.EmployeeService;
  37. @Controller
  38. public class HelloController {
  39.  
  40. @Autowired
  41. EmployeeService emp_service;
  42.  
  43. @RequestMapping("/welcome")
  44. public ModelAndView helloWorld(@ModelAttribute("userForm") Employee employee, ModelMap model) {
  45.  
  46. String message = "Welcome to Java4s.com Spring MVC 4.1.1 Sessions";
  47. message += "<br>You Did it....!";
  48. List<String> professionList = new ArrayList();
  49. professionList.add("Developer");
  50. professionList.add("Designer");
  51. professionList.add("IT Manager");
  52. model.put("professionList", professionList);
  53. return new ModelAndView("welcomePage", "welcomeMessage", new Employee());
  54. }
  55. @RequestMapping(value = "/addemployee", method=RequestMethod.POST)
  56. @DateTimeFormat(pattern="MM/dd/yyyy")
  57. public ModelAndView submitForm(ModelMap model, @ModelAttribute("userForm") Employee employee/*, BindingResult errors*/) {
  58.  
  59. /*if(errors.hasErrors())
  60. {
  61. model.addAttribute("studenterrors", "Errorsssss");
  62. }*/
  63. //System.out.println(student.getBirthdate());
  64. //model.addAttribute("studenterrors", "Errorsssss");
  65. model.addAttribute("username", employee.getUsername());
  66. model.addAttribute("password", employee.getPassword());
  67. model.addAttribute("birthdate", employee.getBirthdate());
  68. model.addAttribute("email", employee.getEmail());
  69. model.addAttribute("professionList", employee.getProfession());
  70. model.addAttribute("userForm", new Employee());
  71.  
  72. emp_service.saveData(employee);
  73. return new ModelAndView("RegisterSuccess",model);
  74. }
  75.  
  76. }
  77.  
  78. /*
  79. * To change this license header, choose License Headers in Project Properties.
  80. * To change this template file, choose Tools | Templates
  81. * and open the template in the editor.
  82. */
  83.  
  84. package java4s;
  85.  
  86. import java4s.Employee;
  87. import org.springframework.jdbc.core.JdbcTemplate;
  88. import javax.sql.DataSource;
  89. import org.springframework.beans.factory.annotation.Autowired;
  90.  
  91. /**
  92. *
  93. * @author Harshit Shrivastava
  94. */
  95. public class EmployeeServiceImpl implements EmployeeService {
  96.  
  97. @Autowired
  98. DataSource dataSource;
  99.  
  100. @Override
  101. public void saveData(Employee employee)
  102. {
  103.  
  104. String query = "INSERT INTO EmployeeInfo(userid,username,firstname,lastname,mobileno,emailid,password,profession) VALUES(?,?,?,?,?,?,?,?)";
  105.  
  106. JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
  107.  
  108.  
  109. }
  110. }
  111.  
  112. <?xml version="1.0" encoding="UTF-8"?>
  113. <beans xmlns="http://www.springframework.org/schema/beans"
  114. xmlns:context="http://www.springframework.org/schema/context"
  115. xmlns:p="http://www.springframework.org/schema/p"
  116. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  117. xsi:schemaLocation="
  118. http://www.springframework.org/schema/beans
  119. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  120. http://www.springframework.org/schema/context
  121. http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  122. xmlns:mvc="http://www.springframework.org/schema/mvc">
  123.  
  124. <context:component-scan base-package="java4s" />
  125. <mvc:annotation-driven />
  126. <bean id="EmployeeService" class="java4s.EmployeeServiceImpl" />
  127.  
  128. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  129. <property name="prefix" value="/jsp/" />
  130. <property name="suffix" value=".jsp" />
  131. </bean>
  132. <bean id="dataSource"
  133. class="org.springframework.jdbc.datasource.DriverManagerDataSource"
  134. p:driverClassName="oracle.jdbc.pool.OracleDataSource"
  135. p:url="jdbc:oracle:thin:@localhost:1521:IM"
  136. p:username="user"
  137. p:password="pass" />
  138. </beans>
  139.  
  140. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from ServletContext resource [/WEB-INF/welcome-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 27; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement