I have followed this to configure spring boot work with JSF and the configuration is ok however I need to get rid of.xhtml suffix in all my jsf using pretty faces. I have so far managed to configure PrettyFaces RewriteFilter in my spring boot and added the URLMapping in my managed bean but it doesnt seem to work am getting ' Whitelabel Error Page '. Here is my login managed bean
@Scope(value = "session")
@Component(value = "loginMgr")
@URLMapping(id = "login",
pattern = "/login",
viewId = "/my_context/login.xhtml")
public class LoginManager {
}
and my pretty faces configuration bean
@Bean
public FilterRegistrationBean prettyFilter() {
System.out.println("pretty filter called");
RewriteFilter filter=new RewriteFilter();
FilterRegistrationBean prettyFilter = new FilterRegistrationBean(filter);
prettyFilter.setDispatcherTypes(DispatcherType.FORWARD, DispatcherType.REQUEST,
DispatcherType.ASYNC, DispatcherType.ERROR);
prettyFilter.addUrlPatterns("/*");
return prettyFilter;
}
and this is my sping boot application.properties
spring.datasource.url= jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=postgres
spring.datasource.password=password
#spring.jpa.show-sql=true
spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
server.context-path=/my_context
spring.security.enabled=false
management.security.enabled=false
security.basic.enabled=false
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrateg
I am using jsf 2.2 and primefaces 5.3 and below are the pretty faces maven dependency
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>3.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-integration-faces</artifactId>
<version>3.4.1.Final</version>
</dependency>
If you would like to get rid of the.xhtml suffix and use MyFaces 2.3, you can simply set: org.apache.myfaces.AUTOMATIC_EXTENSIONLESS_MAPPING
to true
.
So you dont need PrettyFaces or Rewrite.
NOTE: it might throw a exception that #getServletRegistrations
can't be called from a Listener not configured in web.xml
or web-fragment.xml
. In this case you need to add org.apache.myfaces.webapp.StartupServletContextListener
to your web.xml
or web-fragment.xml
..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.