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.
46 lines
1.4 KiB
46 lines
1.4 KiB
package org.pqh.config;
|
|
|
|
import com.alibaba.druid.support.http.StatViewServlet;
|
|
import org.pqh.core.util.LogManger;
|
|
import org.springframework.web.filter.CharacterEncodingFilter;
|
|
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
|
|
|
import javax.servlet.*;
|
|
import java.util.EnumSet;
|
|
|
|
/**
|
|
* Created by reborn on 2017/7/28.
|
|
*/
|
|
|
|
public class AbstractWebConfig extends AbstractAnnotationConfigDispatcherServletInitializer implements LogManger {
|
|
|
|
private String encoding ="UTF-8";
|
|
|
|
@Override
|
|
protected String[] getServletMappings() {
|
|
return new String[]{"*.do"};
|
|
}
|
|
|
|
@Override
|
|
protected Class<?>[] getRootConfigClasses() {
|
|
return new Class[0];
|
|
}
|
|
|
|
@Override
|
|
protected Class<?>[] getServletConfigClasses() {
|
|
return new Class[]{SpringConfig.class};
|
|
}
|
|
|
|
@Override
|
|
public void onStartup(ServletContext servletContext) throws ServletException {
|
|
log.info("onStartup");
|
|
super.onStartup(servletContext);
|
|
FilterRegistration.Dynamic dynamic=super.registerServletFilter(servletContext,new CharacterEncodingFilter(encoding));
|
|
dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),true,"/*");
|
|
|
|
ServletRegistration.Dynamic servlet=servletContext.addServlet("DruidStatView", StatViewServlet.class);
|
|
servlet.addMapping("/druid/*");
|
|
}
|
|
}
|
|
|
|
|
|
|