小编Xav*_*ury的帖子

注释@EnableSpringDataWebSupport不适用于WebMvcConfigurationSupport吗?

我已经使用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一起使用?

spring spring-mvc spring-java-config spring-data-commons

5
推荐指数
1
解决办法
2646
查看次数

是否可以将参数传递给百里香布局 - 方言中的布局?

我有一个共同的布局,默认情况下,应该在每个页面上显示(基本)搜索表单,但搜索页面本身除外,其中包含(更高级)搜索表单.

是否可以将参数从我的搜索页面传递到布局,以便不显示默认搜索表单?

这是我想做的一个例子:

的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)

thymeleaf

5
推荐指数
1
解决办法
9416
查看次数

<partial-response>在WildFly中安全性约束的ajax重定向之后显示为纯文本的XML

我对安全约束的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)

jsf security-constraint omnifaces wildfly partial-response

5
推荐指数
1
解决办法
2226
查看次数