You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
package web.config;
|
|
|
|
import core.dao.BaseDao1;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.PropertySource;
|
|
import org.springframework.orm.hibernate5.support.OpenSessionInViewInterceptor;
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
/**
|
|
* Created by reborn on 2017/7/28.
|
|
*/
|
|
@Configuration
|
|
@EnableWebMvc
|
|
@PropertySource("classpath:config.properties")
|
|
@ComponentScan({"web.controller","web.service"})
|
|
|
|
public class SpringConfig implements WebMvcConfigurer {
|
|
|
|
@Resource
|
|
private BaseDao1 baseDao;
|
|
|
|
@Override
|
|
public void configureViewResolvers(ViewResolverRegistry registry) {
|
|
registry.jsp("/WEB-INF/jsp/",".jsp");
|
|
}
|
|
|
|
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
OpenSessionInViewInterceptor interceptor=new OpenSessionInViewInterceptor();
|
|
interceptor.setSessionFactory(baseDao.getSessionFactory());
|
|
registry.addWebRequestInterceptor(interceptor);
|
|
}
|
|
}
|
|
|