Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. @Controller
  2. public class MainController
  3. {
  4. @Autowired
  5. private ApplicationContextProvider mObjApplicationContextProvider;
  6.  
  7. @Autowired
  8. private ScheduleService mObjScheduleService;
  9.  
  10. protected ApplicationContext getApplicationContext()
  11. {
  12. return(getApplicationContextProvider().getApplicationContext());
  13. }
  14.  
  15. protected ApplicationContextProvider getApplicationContextProvider()
  16. {
  17. return(mObjApplicationContextProvider);
  18. }
  19.  
  20. protected Object getBean(final Class<?> clsBean)
  21. {
  22. return(getApplicationContext().getBean(clsBean));
  23. }
  24.  
  25. protected Object getBean(final String sBeanName)
  26. {
  27. return(getApplicationContext().getBean(sBeanName));
  28. }
  29.  
  30. protected ScheduleService getScheduleService()
  31. {
  32. return(mObjScheduleService);
  33. }
  34.  
  35. @RequestMapping(value="/")
  36. public String index()
  37. {
  38. return("index");
  39. }
  40. }
  41.  
  42. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  47. <title>Insert title here</title>
  48. </head>
  49. <body>
  50. Hello World!
  51. </body>
  52. </html>
  53.  
  54. <beans xmlns="http://www.springframework.org/schema/beans"
  55. xmlns:context="http://www.springframework.org/schema/context"
  56. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  57. xmlns:mvc="http://www.springframework.org/schema/mvc"
  58. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  59. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
  60. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
  61.  
  62. <context:component-scan base-package="net.draconia.church" />
  63.  
  64. <bean class="net.draconia.ApplicationContextProvider" />
  65.  
  66. <bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
  67. <property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
  68. <property name="url" value="jdbc:mysql:sql9.freemysqlhosting.net/sql9158326" />
  69. <property name="username" value="sql9158326" />
  70. <property name="password" value="MqX7sbacgB" />
  71. </bean>
  72.  
  73. <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  74. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
  75. <property name="prefix" value="/WEB-INF/views/jsp/" />
  76. <property name="suffix" value=".jsp" />
  77. </bean>
  78.  
  79. <mvc:resources mapping="/resources/**" location="/resources/" />
  80.  
  81. <mvc:annotation-driven />
  82.  
  83. </beans>
  84.  
  85. public String index()
  86. {
  87. return("index");
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement