Advertisement
Guest User

Untitled

a guest
Jun 18th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. @RequestMapping("/save")
  2. public void save(@RequestParam("firstname") String firstName,@RequestParam("lastname") String lastName,@RequestParam("password") String password ){
  3.  
  4. User e1=new User();
  5.  
  6. e1.setFirstName(firstName);
  7. e1.setLastName(lastName);
  8. e1.setPassword(password);
  9. template.save(e1);
  10.  
  11. ();
  12.  
  13. }
  14.  
  15. HibernateTemplate template=new HibernateTemplate();
  16.  
  17. <beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xmlns:security="http://www.springframework.org/schema/security"
  20. xmlns:context="http://www.springframework.org/schema/context"
  21. xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  22. xmlns="http://www.w3.org/1999/XSL/Transform"
  23. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
  24.  
  25.  
  26. <security:http auto-config="true">
  27. <security:intercept-url pattern="/admin*" access="ROLE_ADMIN" />
  28. <security:form-login login-page="/springtiles/login" default-target-url="/springtiles/admin" authentication-failure-url="/springtiles/error" />
  29. <security:logout logout-success-url="/springtiles/logout" />
  30. </security:http>
  31.  
  32. <security:authentication-manager>
  33. <security:authentication-provider>
  34. <!-- <security:user-service>
  35. <security:user name="admin" password="admin123" authorities="ROLE_ADMIN" />
  36. </security:user-service>-->
  37. <security:jdbc-user-service data-source-ref="dataSource"
  38. users-by-username-query="admin"
  39. authorities-by-username-query="ROLE_ADMIN"
  40. />
  41. <!--</security:authentication-provider>
  42. </security:authentication-manager>-->
  43. <!--<security:authentication-manager>
  44. <security:authentication-provider>
  45. <security:jdbc-user-service data-source-ref="dataSource"
  46.  
  47. users-by-username-query="
  48. select login as username,password
  49. from users100 where login=?"
  50.  
  51. authorities-by-username-query="ROLE_ADMIN"
  52.  
  53. />-->
  54. </security:authentication-provider>
  55. </security:authentication-manager>
  56.  
  57. <beans:bean id="myUserDetailsService"
  58. class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
  59. <beans:property name="dataSource" ref="dataSource"/>
  60. </beans:bean>
  61.  
  62. <beans:bean id="dataSource"
  63. class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  64. <beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
  65. <beans:property name="url" value="jdbc:mysql://localhost:3306/abhi" />
  66. <beans:property name="username" value="root" />
  67. <beans:property name="password" value="system" />
  68. </beans:bean>
  69. <beans:bean id="mysessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  70. <beans:property name="dataSource" ref="dataSource"></beans:property>
  71.  
  72. <beans:property name="mappingResources">
  73. <beans:list>
  74. <beans:value>User.hbm.xml</beans:value>
  75. </beans:list>
  76. </beans:property>
  77.  
  78. <beans:property name="hibernateProperties">
  79. <beans:props>
  80. <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop>
  81.  
  82. <beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
  83. <beans:prop key="hibernate.show_sql">true</beans:prop>
  84.  
  85. </beans:props>
  86. </beans:property>
  87. </beans:bean>
  88.  
  89. <beans:bean id="template" class="org.springframework.orm.hibernate3.HibernateTemplate">
  90. <beans:property name="sessionFactory" ref="mysessionFactory"></beans:property>
  91. </beans:bean>
  92.  
  93. <beans:bean id="d" class="com.abhishek.HelloWorldController">
  94. <beans:property name="template" ref="template"></beans:property>
  95. </beans:bean>
  96. <!---<jdbc:embedded-database id="dataSource"/>-->
  97. </beans:beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement