我已经使用WebMvcConfigurerAdapter已有一段时间了。由于无法使用getInterceptors()方法获取所有已注册的拦截器,因此我切换到了WebMvcConfigurationSupport,它具有许多默认的已注册Spring Bean,例如ContentNegotiationManager,ExceptionHandlerExceptionResolverusw。
现在,我已经意识到,尽管我在WebConfig类上使用了@EnableSpringDataWebSupport批注,但非常方便的DomainClassConverter(使用CrudRepository将域类ID转换为域类对象)并未默认注册。
当我像这样显式定义此bean时,它就会起作用。
@EnableSpringDataWebSupport
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {
@Bean
public DomainClassConverter<?> domainClassConverter() {
return new DomainClassConverter<FormattingConversionService>(mvcConversionService());
}
}
Run Code Online (Sandbox Code Playgroud)
但是,为什么EnableSpringDataWebSupport无法与WebMvcConfigurationSupport一起使用?
我有一个共同的布局,默认情况下,应该在每个页面上显示(基本)搜索表单,但搜索页面本身除外,其中包含(更高级)搜索表单.
是否可以将参数从我的搜索页面传递到布局,以便不显示默认搜索表单?
这是我想做的一个例子:
的layout.html
<html layout:???="displayShowForm = true">
...
<form action="search" th:if="${displayShowForm}">...</form>
...
<div layout:fragment="content">...</div>
Run Code Online (Sandbox Code Playgroud)
home.html(显示默认搜索表单)
<html layout:decorator="layout">
...
<div layout:fragment="content">...</div>
Run Code Online (Sandbox Code Playgroud)
search.html(隐藏默认搜索表单)
<html layout:decorator="layout (displayShowForm = false)">
...
<div layout:fragment="content">
...
<form action="advancedSearch">...</form>
Run Code Online (Sandbox Code Playgroud) 我对安全约束的ajax重定向有这个奇怪的问题:
在会话超时后,在角色安全页面上进行ajax调用(通过单击可排序p:dataTable列或p:poll触发器)时,<partial-response><redirect-url=...屏幕上会显示OmniFaces中的XML.
当我删除OmniFaces时,ajax调用似乎无声地失败,我没有显示XML.
安全性在web.xml中配置如下:
<security-constraint>
<web-resource-collection>
<web-resource-name>Pages</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Resources</web-resource-name>
<url-pattern>/javax.faces.resource/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>myRealm</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/login.xhtml?error=true</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
Run Code Online (Sandbox Code Playgroud)