본문 바로가기

Development/Web & Server

[Spring Framework] Spring + Hibernate으로 JSON 출력하기 (2) - Hibernate Setting

web.xml에 넣어준다.


<filter>

<filter-name>HibernateSession</filter-name>

<filter-class>

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

</filter-class>

</filter>


<filter-mapping>

<filter-name>HibernateSession</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>


Resource 폴더에 applicationContext-hibernate.xml 만든다.

그리고 web.xml


<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring/root-context.xml

        classpath:org/hibernate/**/applicationContext*.xml</param-value>

</context-param>


다음과 같이 읽을수 있도록 연결


이제 Hibernate에서 매핑작업을 진행하면 된다.~! 그전에 Mysql에서 테이블을 임의로 만든다.