Skip to content

Instantly share code, notes, and snippets.

@KupchenkoArtur
Created February 2, 2023 10:18
Show Gist options
  • Save KupchenkoArtur/d4eb10f70491b6bd1cfb4cde644ac905 to your computer and use it in GitHub Desktop.
Save KupchenkoArtur/d4eb10f70491b6bd1cfb4cde644ac905 to your computer and use it in GitHub Desktop.
package web.config;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
public class AppInit extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[]{HiberConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[]{
WebConfig.class
};
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
@Override
public void onStartup(ServletContext aServletContext) throws ServletException {
super.onStartup(aServletContext);
registerHiddenFieldFilter(aServletContext);
}
private void registerHiddenFieldFilter(ServletContext aContext) {
aContext.addFilter("hiddenHttpMethodFilter",
new HiddenHttpMethodFilter()).addMappingForUrlPatterns(null, true, "/*");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment