Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="ISO-8859-1" ?>
- <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
- <jsp:directive.page contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1" session="false"/>
- <jsp:output doctype-root-element="html"
- doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
- doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
- omit-xml-declaration="true" />
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Welcome</title>
- </head>
- <body>
- <a href="welcome">Welcome Guest</a>
- </body>
- </html>
- </jsp:root>
- package java4s;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.ui.ModelMap;
- import org.springframework.format.annotation.DateTimeFormat;
- import java.util.ArrayList;
- import java.util.List;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import org.springframework.beans.factory.annotation.Autowired;
- import java4s.EmployeeService;
- @Controller
- public class HelloController {
- @Autowired
- EmployeeService emp_service;
- @RequestMapping("/welcome")
- public ModelAndView helloWorld(@ModelAttribute("userForm") Employee employee, ModelMap model) {
- String message = "Welcome to Java4s.com Spring MVC 4.1.1 Sessions";
- message += "<br>You Did it....!";
- List<String> professionList = new ArrayList();
- professionList.add("Developer");
- professionList.add("Designer");
- professionList.add("IT Manager");
- model.put("professionList", professionList);
- return new ModelAndView("welcomePage", "welcomeMessage", new Employee());
- }
- @RequestMapping(value = "/addemployee", method=RequestMethod.POST)
- @DateTimeFormat(pattern="MM/dd/yyyy")
- public ModelAndView submitForm(ModelMap model, @ModelAttribute("userForm") Employee employee/*, BindingResult errors*/) {
- /*if(errors.hasErrors())
- {
- model.addAttribute("studenterrors", "Errorsssss");
- }*/
- //System.out.println(student.getBirthdate());
- //model.addAttribute("studenterrors", "Errorsssss");
- model.addAttribute("username", employee.getUsername());
- model.addAttribute("password", employee.getPassword());
- model.addAttribute("birthdate", employee.getBirthdate());
- model.addAttribute("email", employee.getEmail());
- model.addAttribute("professionList", employee.getProfession());
- model.addAttribute("userForm", new Employee());
- emp_service.saveData(employee);
- return new ModelAndView("RegisterSuccess",model);
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package java4s;
- import java4s.Employee;
- import org.springframework.jdbc.core.JdbcTemplate;
- import javax.sql.DataSource;
- import org.springframework.beans.factory.annotation.Autowired;
- /**
- *
- * @author Harshit Shrivastava
- */
- public class EmployeeServiceImpl implements EmployeeService {
- @Autowired
- DataSource dataSource;
- @Override
- public void saveData(Employee employee)
- {
- String query = "INSERT INTO EmployeeInfo(userid,username,firstname,lastname,mobileno,emailid,password,profession) VALUES(?,?,?,?,?,?,?,?)";
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd"
- xmlns:mvc="http://www.springframework.org/schema/mvc">
- <context:component-scan base-package="java4s" />
- <mvc:annotation-driven />
- <bean id="EmployeeService" class="java4s.EmployeeServiceImpl" />
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource"
- p:driverClassName="oracle.jdbc.pool.OracleDataSource"
- p:url="jdbc:oracle:thin:@localhost:1521:IM"
- p:username="user"
- p:password="pass" />
- </beans>
- 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