Web implementation of the Gourmet Recipe Manager
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.
 
 
 
 

73 lines
2.3 KiB

package com.mousetech.gourmetj;
import jakarta.faces.application.ViewExpiredException;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
@SpringBootApplication
@ServletComponentScan
@EntityScan(value = {
"com.mousetech.gourmetj.persistence.model" })
public class SpringPrimeFacesApplication {
final String homePage = "/main.jsf?viewExpired=true";
final String errorPage = "/error/error.html";
final String error404Page = "/error/error404.jsp";
final String error400Page = "/error/error400.jsp";
final String expiredPage = "/error/viewExpired.xhtml";
public static void main(String[] args) {
SpringApplication.run(SpringPrimeFacesApplication.class,
args);
}
@Bean
public ServletContextInitializer initializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
servletContext.setInitParameter(
"jakarta.faces.FACELETS_SKIP_COMMENTS",
"true");
servletContext.setInitParameter(
"com.sun.faces.expressionFactory",
"com.sun.el.ExpressionFactoryImpl");
servletContext.setInitParameter(
"primefaces.UPLOADER", "native");
}
};
}
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new ErrorPageRegistrar() {
@Override
public void registerErrorPages(
ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(
HttpStatus.NOT_FOUND, error404Page));
registry.addErrorPages(new ErrorPage(
ViewExpiredException.class,
expiredPage));
registry.addErrorPages(new ErrorPage(
HttpStatus.INTERNAL_SERVER_ERROR,
errorPage));
registry.addErrorPages(new ErrorPage(
HttpStatus.BAD_REQUEST,
error400Page));
}
};
}
}