entry : subProperties.entrySet()) {
47 | properties.put(entry.getKey(), entry.getValue().toString());
48 | }
49 |
50 | return new ConfigurableContentNegotiationManagerWebMvcConfigurer(properties);
51 |
52 | }
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/autoconfigure/ExclusiveViewResolverConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.spring.web.context.ExclusiveViewResolverApplicationListener;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 | import org.springframework.web.servlet.ViewResolver;
10 |
11 | import static com.alibaba.boot.web.util.WebSupportUtils.VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME;
12 |
13 | /**
14 | * Exclusive {@link ViewResolver} {@link Configuration}
15 | *
16 | * @author Mercy
17 | * @see ViewResolver
18 | * @see Configuration
19 | * @since 2017.03.23
20 | */
21 | @ConditionalOnWebApplication
22 | @ConditionalOnProperty(VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME)
23 | public class ExclusiveViewResolverConfiguration {
24 |
25 | @Bean
26 | public ExclusiveViewResolverApplicationListener exclusiveViewResolverApplicationListener
27 | (@Value("${" + VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME + "}") String exclusiveViewResolverBeanName) {
28 |
29 | ExclusiveViewResolverApplicationListener applicationListener =
30 | new ExclusiveViewResolverApplicationListener(exclusiveViewResolverBeanName);
31 |
32 | return applicationListener;
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/autoconfigure/SpeedupWebMvcAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.filter.NoopOrderedHiddenHttpMethodFilter;
4 | import com.alibaba.boot.web.filter.NoopOrderedHttpPutFormContentFilter;
5 | import org.springframework.boot.autoconfigure.AutoConfigureAfter;
6 | import org.springframework.boot.autoconfigure.AutoConfigureBefore;
7 | import org.springframework.boot.autoconfigure.AutoConfigureOrder;
8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
10 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
11 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
12 | import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
13 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
14 | import org.springframework.context.annotation.Bean;
15 | import org.springframework.core.Ordered;
16 | import org.springframework.web.filter.HiddenHttpMethodFilter;
17 | import org.springframework.web.filter.HttpPutFormContentFilter;
18 | import org.springframework.web.servlet.DispatcherServlet;
19 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
20 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
21 |
22 | import javax.servlet.Servlet;
23 |
24 | import static com.alibaba.boot.web.util.WebSupportUtils.NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME;
25 | import static com.alibaba.boot.web.util.WebSupportUtils.NOOP_HTTP_PUT_FORM_CONTENT_FILTER_ENABLED_PROPERTY_NAME;
26 |
27 | /**
28 | * Speed up {@link WebMvcAutoConfiguration} , auto configure before {@link WebMvcAutoConfiguration} and
29 | * after {@link DispatcherServletAutoConfiguration} , which speeds up execution time and improves performances.
30 | *
31 | * @author Mercy
32 | * @see WebMvcAutoConfiguration
33 | * @see DispatcherServletAutoConfiguration
34 | * @since 2017.04.11
35 | */
36 | @ConditionalOnWebApplication
37 | @ConditionalOnClass({Servlet.class, DispatcherServlet.class,
38 | WebMvcConfigurerAdapter.class})
39 | @ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
40 | @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10)
41 | @AutoConfigureBefore(name = {
42 | "org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration", // compatible with Spring Boot 1.x
43 | "org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration" // compatible with Spring Boot 2.0
44 | })
45 | @AutoConfigureAfter(name = {
46 | "org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration", // compatible with Spring Boot 1.x
47 | "org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration" // compatible with Spring Boot 2.0
48 | })
49 | public class SpeedupWebMvcAutoConfiguration {
50 |
51 | @Bean
52 | @ConditionalOnProperty(value = NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME, havingValue = "true")
53 | @ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
54 | public NoopOrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
55 | return new NoopOrderedHiddenHttpMethodFilter();
56 | }
57 |
58 | /**
59 | * spring.mvc.formcontent.putfilter property since 1.4.1.RELEASE
60 | */
61 | @Bean
62 | @ConditionalOnProperty(value = {NOOP_HTTP_PUT_FORM_CONTENT_FILTER_ENABLED_PROPERTY_NAME}, havingValue = "true")
63 | @ConditionalOnMissingBean(HttpPutFormContentFilter.class)
64 | public NoopOrderedHttpPutFormContentFilter httpPutFormContentFilter() {
65 | return new NoopOrderedHttpPutFormContentFilter();
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/condition/ConditionalOnPropertyPrefix.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.condition;
2 |
3 | import org.springframework.context.annotation.Conditional;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * {@link Conditional} that checks if the prefix of properties are found in environment..
12 | *
13 | * @author Mercy
14 | * @see OnPropertyPrefixCondition
15 | * @since 2017.03.29
16 | */
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target({ElementType.TYPE, ElementType.METHOD})
19 | @Conditional(OnPropertyPrefixCondition.class)
20 | public @interface ConditionalOnPropertyPrefix {
21 |
22 | /**
23 | * The prefix values of properties.
24 | *
25 | * The prefix automatically ends
26 | * with a dot if not specified.
27 | *
28 | * @return prefix values of properties.
29 | */
30 | String[] value();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/condition/OnPropertyPrefixCondition.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.condition;
2 |
3 | import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
4 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
5 | import org.springframework.context.annotation.Condition;
6 | import org.springframework.context.annotation.ConditionContext;
7 | import org.springframework.core.annotation.AnnotationAttributes;
8 | import org.springframework.core.env.ConfigurableEnvironment;
9 | import org.springframework.core.env.EnumerablePropertySource;
10 | import org.springframework.core.env.MutablePropertySources;
11 | import org.springframework.core.env.PropertySource;
12 | import org.springframework.core.type.AnnotatedTypeMetadata;
13 |
14 | import java.util.Arrays;
15 |
16 | /**
17 | * {@link Condition} that checks if the prefix of properties are found in environment.
18 | *
19 | * @author Mercy
20 | * @see SpringBootCondition
21 | * @see ConditionalOnPropertyPrefix
22 | * @since 2017.03.29
23 | */
24 | public class OnPropertyPrefixCondition extends SpringBootCondition {
25 |
26 | @Override
27 | public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
28 |
29 | AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(
30 | metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName()));
31 |
32 | String[] prefixValues = annotationAttributes.getStringArray("value");
33 |
34 | ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
35 |
36 | boolean matched = false;
37 |
38 | for (String prefix : prefixValues) {
39 |
40 | if (startsWith(environment, prefix)) {
41 | matched = true;
42 | break;
43 | }
44 |
45 | }
46 |
47 | return matched ? ConditionOutcome.match() : ConditionOutcome.noMatch("The prefix values " +
48 | Arrays.asList(prefixValues) + " were not found in Environment!");
49 |
50 | }
51 |
52 | private boolean startsWith(ConfigurableEnvironment environment, String prefix) {
53 |
54 | final String actualPrefix = prefix.endsWith(".") ? prefix : prefix + ".";
55 |
56 | boolean started = false;
57 |
58 | MutablePropertySources mutablePropertySources = environment.getPropertySources();
59 |
60 | for (PropertySource propertySource : mutablePropertySources) {
61 |
62 | if (propertySource instanceof EnumerablePropertySource) {
63 |
64 | EnumerablePropertySource source = EnumerablePropertySource.class.cast(propertySource);
65 |
66 | String[] propertyNames = source.getPropertyNames();
67 |
68 | for (String propertyName : propertyNames) {
69 |
70 | if (propertyName.startsWith(actualPrefix)) {
71 | started = true;
72 | break;
73 | }
74 |
75 | }
76 |
77 | }
78 |
79 | }
80 |
81 | return started;
82 |
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/filter/NoopOrderedHiddenHttpMethodFilter.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.filter;
2 |
3 | import org.springframework.core.Ordered;
4 | import org.springframework.web.filter.HiddenHttpMethodFilter;
5 |
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServletRequest;
8 |
9 | /**
10 | * {@link Ordered} No-Operation {@link HiddenHttpMethodFilter}
11 | *
12 | * @author Mercy
13 | * @see HiddenHttpMethodFilter
14 | * @since 2017.03.21
15 | */
16 | public final class NoopOrderedHiddenHttpMethodFilter extends HiddenHttpMethodFilter implements Ordered {
17 |
18 | private int order = -10000;
19 |
20 | protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
21 |
22 | return true;
23 |
24 | }
25 |
26 | public void setOrder(int order) {
27 | this.order = order;
28 | }
29 |
30 | @Override
31 | public int getOrder() {
32 | return order;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/filter/NoopOrderedHttpPutFormContentFilter.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.filter;
2 |
3 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
4 | import org.springframework.core.Ordered;
5 | import org.springframework.web.filter.HttpPutFormContentFilter;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.http.HttpServletRequest;
9 |
10 | /**
11 | * {@link Ordered} No-Operation {@link HttpPutFormContentFilter}
12 | *
13 | * @author Mercy
14 | * @see HttpPutFormContentFilter
15 | * @see WebMvcAutoConfiguration#httpPutFormContentFilter()
16 | * @since 2017.03.21
17 | */
18 | public final class NoopOrderedHttpPutFormContentFilter extends HttpPutFormContentFilter implements Ordered {
19 |
20 | private int order = -9900;
21 |
22 | protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
23 |
24 | return true;
25 |
26 | }
27 |
28 | public void setOrder(int order) {
29 | this.order = order;
30 | }
31 |
32 | @Override
33 | public int getOrder() {
34 | return order;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/util/ViewResolverUtils.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.util;
2 |
3 | import org.springframework.web.servlet.ViewResolver;
4 |
5 | /**
6 | * {@link ViewResolver} Utilities
7 | *
8 | * @author Mercy
9 | * @see ViewResolver
10 | * @since 2017.03.22
11 | */
12 | public class ViewResolverUtils {
13 |
14 | /**
15 | * The bean name of InternalResourceViewResolver
16 | */
17 | public static final String INTERNAL_RESOURCE_VIEW_RESOLVER_BEAN_NAME = "defaultViewResolver";
18 |
19 | /**
20 | * The bean name of org.springframework.web.servlet.view.velocity.VelocityViewResolver
21 | */
22 | public static final String VELOCITY_VIEW_RESOLVER_BEAN_NAME = "velocityViewResolver";
23 |
24 | /**
25 | * The bean name of org.thymeleaf.spring5.view.ThymeleafViewResolver
26 | */
27 | public static final String THYMELEAF_VIEW_RESOLVER_BEAN_NAME = "thymeleafViewResolver";
28 |
29 | /**
30 | * The bean name of org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver
31 | */
32 | public static final String FREEMARKER_VIEW_RESOLVER_BEAN_NAME = "freeMarkerViewResolver";
33 |
34 | /**
35 | * The bean name of org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver
36 | */
37 | public static final String GROOVY_MARKUP_VIEW_RESOLVER_BEAN_NAME = "groovyMarkupViewResolver";
38 |
39 | /**
40 | * The bean name of org.springframework.boot.web.servlet.view.MustacheViewResolver
41 | */
42 | public static final String MUSTACHE_VIEW_RESOLVER_BEAN_NAME = "mustacheViewResolver";
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/java/com/alibaba/boot/web/util/WebSupportUtils.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.util;
2 |
3 | import com.alibaba.boot.web.filter.NoopOrderedHiddenHttpMethodFilter;
4 | import com.alibaba.boot.web.filter.NoopOrderedHttpPutFormContentFilter;
5 | import org.springframework.web.accept.ContentNegotiationManager;
6 | import org.springframework.web.servlet.ViewResolver;
7 |
8 | /**
9 | * Web Support Utilities
10 | *
11 | * @author Mercy
12 | * @since 2017.03.29
13 | */
14 | public abstract class WebSupportUtils {
15 |
16 | /**
17 | * The prefix of property name
18 | */
19 | public static final String PROPERTY_NAME_PREFIX = "web-support.";
20 |
21 | /**
22 | * The prefix of property name of {@link ContentNegotiationManager}
23 | */
24 | public static final String CONTENT_NEGOTIATION_MANAGER_PROPERTY_NAME_PREFIX = PROPERTY_NAME_PREFIX +
25 | "content-negotiation-manager";
26 |
27 | /**
28 | * The property name of exclusive bean name of {@link ViewResolver}s.
29 | */
30 | public static final String VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME = PROPERTY_NAME_PREFIX
31 | + "exclusive-view-resolver";
32 |
33 | /**
34 | * The property name of class name of {@link NoopOrderedHiddenHttpMethodFilter}
35 | */
36 | public static final String NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME =
37 | PROPERTY_NAME_PREFIX + "noop.httpmethod.hiddenfilter.enabled";
38 |
39 | /**
40 | * The property name of class name of {@link NoopOrderedHttpPutFormContentFilter}
41 | */
42 | public static final String NOOP_HTTP_PUT_FORM_CONTENT_FILTER_ENABLED_PROPERTY_NAME =
43 | PROPERTY_NAME_PREFIX + "noop.formcontent.putfilter.enabled";
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | # Register EnableAutoConfiguration
2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
3 | com.alibaba.boot.web.autoconfigure.ExclusiveViewResolverConfiguration,\
4 | com.alibaba.boot.web.autoconfigure.ContentNegotiationManagerConfiguration,\
5 | com.alibaba.boot.web.autoconfigure.SpeedupWebMvcAutoConfiguration
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/boot/BootApplication.java:
--------------------------------------------------------------------------------
1 | package boot;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | /**
8 | * Spring Boot Application
9 | *
10 | * @author Mercy
11 | * @see SpringBootApplication
12 | * @since 2017.03.29
13 | */
14 | @EnableAutoConfiguration
15 | public class BootApplication {
16 |
17 | public static void main(String[] args) {
18 | SpringApplication.run(BootApplication.class, args);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/AbstractSpringBootTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web;
2 |
3 | import boot.BootApplication;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.test.context.SpringBootTest;
7 | import org.springframework.context.ApplicationContext;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | /**
11 | * {@link AbstractSpringBootTest}
12 | *
13 | * @author Mercy
14 | * @version 1.0.0
15 | * @see AbstractSpringBootTest
16 | * @since 1.0.0 2016-07-18
17 | */
18 |
19 | @RunWith(SpringRunner.class)
20 | @SpringBootTest(classes = BootApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
21 | public abstract class AbstractSpringBootTest {
22 |
23 | @Autowired
24 | protected ApplicationContext applicationContext;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/ContentNegotiationManagerConfigurationDisabledTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.spring.util.BeanUtils;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.test.context.ActiveProfiles;
9 | import org.springframework.web.accept.ContentNegotiationManager;
10 | import org.springframework.web.accept.ContentNegotiationStrategy;
11 | import org.springframework.web.accept.HeaderContentNegotiationStrategy;
12 | import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * {@link ContentNegotiationManagerConfiguration} Test
18 | *
19 | * @author Mercy
20 | * @see ContentNegotiationManagerConfiguration
21 | * @since 2017.03.29
22 | */
23 | @ActiveProfiles("disabled")
24 | public class ContentNegotiationManagerConfigurationDisabledTest extends AbstractSpringBootTest {
25 |
26 | @Autowired
27 | private ContentNegotiatingViewResolver contentNegotiatingViewResolver;
28 |
29 | @Test
30 | public void testContentNegotiationManagerConfigurationOnDisabled() {
31 |
32 | Assert.assertFalse(BeanUtils.isBeanPresent(applicationContext, ContentNegotiationManagerConfiguration.class));
33 |
34 | ContentNegotiationManager contentNegotiationManager =
35 | contentNegotiatingViewResolver.getContentNegotiationManager();
36 |
37 | List strategies = contentNegotiationManager.getStrategies();
38 |
39 | Assert.assertEquals(1, strategies.size());
40 | Assert.assertTrue(contains(HeaderContentNegotiationStrategy.class, strategies));
41 |
42 | }
43 |
44 | private boolean contains(Class extends ContentNegotiationStrategy> strategyClass,
45 | List strategies) {
46 |
47 | boolean contained = false;
48 |
49 | for (ContentNegotiationStrategy strategy : strategies) {
50 |
51 | contained = strategyClass.isInstance(strategy);
52 |
53 | if (contained) {
54 | break;
55 | }
56 |
57 | }
58 |
59 | return contained;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/ContentNegotiationManagerConfigurationTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.spring.util.FieldUtils;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.ActiveProfiles;
10 | import org.springframework.web.accept.ContentNegotiationManager;
11 | import org.springframework.web.accept.ContentNegotiationStrategy;
12 | import org.springframework.web.accept.FixedContentNegotiationStrategy;
13 | import org.springframework.web.accept.HeaderContentNegotiationStrategy;
14 | import org.springframework.web.accept.ParameterContentNegotiationStrategy;
15 | import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
16 |
17 | import java.util.List;
18 | import java.util.Map;
19 |
20 | /**
21 | * {@link ContentNegotiationManagerConfiguration} Test
22 | *
23 | * @author Mercy
24 | * @see ContentNegotiationManagerConfiguration
25 | * @since 2017.03.29
26 | */
27 | @ActiveProfiles("enabled")
28 | public class ContentNegotiationManagerConfigurationTest extends AbstractSpringBootTest {
29 |
30 | @Autowired
31 | private ContentNegotiationManagerConfiguration contentNegotiationManagerConfiguration;
32 |
33 | @Autowired
34 | private ContentNegotiatingViewResolver contentNegotiatingViewResolver;
35 |
36 | /**
37 | * spring.web-support.content-negotiation-manager.favorPathExtension = true
38 | * spring.web-support.content-negotiation-manager.favorParameter = true
39 | * spring.web-support.content-negotiation-manager.ignoreAcceptHeader = false
40 | * spring.web-support.content-negotiation-manager.useJaf = false
41 | * spring.web-support.content-negotiation-manager.parameterName = test-format
42 | * spring.web-support.content-negotiation-manager.mediaTypes.html = text/html
43 | * spring.web-support.content-negotiation-manager.mediaTypes.xml = text/xml
44 | * spring.web-support.content-negotiation-manager.mediaTypes.json = application/json
45 | * spring.web-support.content-negotiation-manager.mediaTypes.gif = image/gif
46 | * spring.web-support.content-negotiation-manager.mediaTypes.jpeg = image/jpeg
47 | * spring.web-support.content-negotiation-manager.defaultContentType = text/html
48 | */
49 | @Test
50 | public void testContentNegotiationManagerConfiguration() {
51 |
52 | ContentNegotiationManager contentNegotiationManager =
53 | contentNegotiatingViewResolver.getContentNegotiationManager();
54 |
55 | List strategies = contentNegotiationManager.getStrategies();
56 |
57 | Assert.assertEquals(4, strategies.size());
58 | Assert.assertTrue(contains(ParameterContentNegotiationStrategy.class, strategies));
59 | Assert.assertTrue(contains(HeaderContentNegotiationStrategy.class, strategies));
60 | Assert.assertTrue(contains(FixedContentNegotiationStrategy.class, strategies));
61 |
62 | ContentNegotiationStrategy strategy = strategies.get(0);
63 |
64 | strategy = FieldUtils.getFieldValue(strategy, "delegate");
65 |
66 | Map mediaTypesMap = FieldUtils.getFieldValue(strategy, "mediaTypes");
67 |
68 | Assert.assertEquals("html", mediaTypesMap.get("html").getSubtype());
69 | Assert.assertEquals("xml", mediaTypesMap.get("xml").getSubtype());
70 | Assert.assertEquals("json", mediaTypesMap.get("json").getSubtype());
71 | Assert.assertEquals("gif", mediaTypesMap.get("gif").getSubtype());
72 | Assert.assertEquals("jpeg", mediaTypesMap.get("jpeg").getSubtype());
73 |
74 | }
75 |
76 | private boolean contains(Class extends ContentNegotiationStrategy> strategyClass,
77 | List strategies) {
78 |
79 | boolean contained = false;
80 |
81 | for (ContentNegotiationStrategy strategy : strategies) {
82 |
83 | contained = strategyClass.isInstance(strategy);
84 |
85 | if (contained) {
86 | break;
87 | }
88 |
89 | }
90 |
91 | return contained;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/ExclusiveViewResolverConfigurationDisabledTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.spring.util.BeanUtils;
5 | import com.alibaba.spring.web.context.ExclusiveViewResolverApplicationListener;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 | import org.springframework.test.context.ActiveProfiles;
9 | import org.springframework.web.servlet.ViewResolver;
10 | import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
11 | import org.thymeleaf.spring5.view.ThymeleafViewResolver;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * {@link ExclusiveViewResolverConfiguration} Disabled Test
17 | *
18 | * @author Mercy
19 | * @see ExclusiveViewResolverConfiguration
20 | * @since 2017.03.29
21 | */
22 | @ActiveProfiles("disabled")
23 | public class ExclusiveViewResolverConfigurationDisabledTest extends AbstractSpringBootTest {
24 |
25 | @Test
26 | public void testExclusiveViewResolverConfigurationDisabled() {
27 |
28 | Assert.assertFalse(BeanUtils.isBeanPresent(applicationContext, ExclusiveViewResolverConfiguration.class));
29 | Assert.assertFalse(BeanUtils.isBeanPresent(applicationContext, ExclusiveViewResolverApplicationListener.class));
30 |
31 | ContentNegotiatingViewResolver contentNegotiatingViewResolver =
32 | applicationContext.getBean(ContentNegotiatingViewResolver.class);
33 |
34 | Assert.assertNotNull(contentNegotiatingViewResolver);
35 |
36 | List viewResolvers = contentNegotiatingViewResolver.getViewResolvers();
37 |
38 | Assert.assertTrue(viewResolvers.size() > 1);
39 |
40 | ThymeleafViewResolver thymeleafViewResolver =
41 | applicationContext.getBean("thymeleafViewResolver", ThymeleafViewResolver.class);
42 |
43 | Assert.assertTrue(viewResolvers.contains(thymeleafViewResolver));
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/ExclusiveViewResolverConfigurationTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.spring.util.BeanUtils;
5 | import com.alibaba.spring.web.context.ExclusiveViewResolverApplicationListener;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 | import org.springframework.test.context.ActiveProfiles;
9 | import org.springframework.web.servlet.ViewResolver;
10 | import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
11 | import org.thymeleaf.spring5.view.ThymeleafViewResolver;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * {@link ExclusiveViewResolverConfiguration} Test
17 | *
18 | * @author Mercy
19 | * @see ExclusiveViewResolverConfiguration
20 | * @since 2017.03.29
21 | */
22 | @ActiveProfiles("enabled")
23 | public class ExclusiveViewResolverConfigurationTest extends AbstractSpringBootTest {
24 |
25 | @Test
26 | public void testExclusiveViewResolverConfiguration() {
27 |
28 | Assert.assertTrue(BeanUtils.isBeanPresent(applicationContext, ExclusiveViewResolverConfiguration.class));
29 | Assert.assertTrue(BeanUtils.isBeanPresent(applicationContext, ExclusiveViewResolverApplicationListener.class));
30 |
31 | ContentNegotiatingViewResolver contentNegotiatingViewResolver =
32 | applicationContext.getBean(ContentNegotiatingViewResolver.class);
33 |
34 | Assert.assertNotNull(contentNegotiatingViewResolver);
35 |
36 | List viewResolvers = contentNegotiatingViewResolver.getViewResolvers();
37 |
38 | Assert.assertEquals(1, viewResolvers.size());
39 |
40 | ThymeleafViewResolver thymeleafViewResolver =
41 | applicationContext.getBean("thymeleafViewResolver", ThymeleafViewResolver.class);
42 |
43 | Assert.assertEquals(thymeleafViewResolver, viewResolvers.get(0));
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/SpeedupWebMvcAutoConfigurationDisabledTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.boot.web.filter.NoopOrderedHiddenHttpMethodFilter;
5 | import com.alibaba.boot.web.filter.NoopOrderedHttpPutFormContentFilter;
6 | import com.alibaba.spring.util.BeanUtils;
7 | import org.junit.Assert;
8 | import org.junit.Test;
9 | import org.springframework.test.context.ActiveProfiles;
10 |
11 | import javax.servlet.ServletException;
12 | import java.io.IOException;
13 |
14 | /**
15 | * {@link SpeedupWebMvcAutoConfiguration} Test with "disabled" profile
16 | *
17 | * @author Mercy
18 | * @see SpeedupWebMvcAutoConfiguration
19 | * @since 2017.04.11
20 | */
21 | @ActiveProfiles("disabled")
22 | public class SpeedupWebMvcAutoConfigurationDisabledTest extends AbstractSpringBootTest {
23 |
24 | @Test
25 | public void testNoopOrderedHiddenHttpMethodFilter() throws ServletException, IOException {
26 |
27 | Assert.assertFalse(BeanUtils.isBeanPresent(applicationContext, NoopOrderedHiddenHttpMethodFilter.class));
28 |
29 | }
30 |
31 | @Test
32 | public void testNoopOrderedHttpPutFormContentFilter() throws ServletException, IOException {
33 |
34 | Assert.assertFalse(BeanUtils.isBeanPresent(applicationContext, NoopOrderedHttpPutFormContentFilter.class));
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/autoconfigure/SpeedupWebMvcAutoConfigurationTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.autoconfigure;
2 |
3 | import com.alibaba.boot.web.AbstractSpringBootTest;
4 | import com.alibaba.boot.web.filter.NoopOrderedHiddenHttpMethodFilter;
5 | import com.alibaba.boot.web.filter.NoopOrderedHttpPutFormContentFilter;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 | import org.springframework.mock.web.MockFilterChain;
9 | import org.springframework.mock.web.MockHttpServletRequest;
10 | import org.springframework.mock.web.MockHttpServletResponse;
11 | import org.springframework.test.context.ActiveProfiles;
12 |
13 | import javax.servlet.ServletException;
14 | import javax.servlet.http.HttpServletRequestWrapper;
15 | import java.io.IOException;
16 |
17 | /**
18 | * {@link SpeedupWebMvcAutoConfiguration} Test
19 | *
20 | * @author Mercy
21 | * @see SpeedupWebMvcAutoConfiguration
22 | * @since 2017.04.11
23 | */
24 | @ActiveProfiles("enabled")
25 | public class SpeedupWebMvcAutoConfigurationTest extends AbstractSpringBootTest {
26 |
27 |
28 | @Test
29 | public void testNoopOrderedHiddenHttpMethodFilter() throws ServletException, IOException {
30 |
31 | NoopOrderedHiddenHttpMethodFilter filter = applicationContext.getBean(NoopOrderedHiddenHttpMethodFilter.class);
32 |
33 | MockHttpServletRequest request = new MockHttpServletRequest();
34 | request.setMethod("POST");
35 | request.setParameter("_method", "action");
36 |
37 | MockHttpServletResponse response = new MockHttpServletResponse();
38 |
39 | MockFilterChain filterChain = new MockFilterChain();
40 |
41 | filter.doFilter(request, response, filterChain);
42 |
43 | Assert.assertFalse(HttpServletRequestWrapper.class.isAssignableFrom(filterChain.getRequest().getClass()));
44 | Assert.assertTrue(MockHttpServletRequest.class.isAssignableFrom(filterChain.getRequest().getClass()));
45 |
46 | }
47 |
48 | @Test
49 | public void testNoopOrderedHttpPutFormContentFilter() throws ServletException, IOException {
50 |
51 | NoopOrderedHttpPutFormContentFilter filter = applicationContext.getBean(NoopOrderedHttpPutFormContentFilter.class);
52 |
53 | MockHttpServletRequest request = new MockHttpServletRequest();
54 | request.setMethod("PUT");
55 |
56 | MockHttpServletResponse response = new MockHttpServletResponse();
57 |
58 | MockFilterChain filterChain = new MockFilterChain();
59 |
60 | filter.doFilter(request, response, filterChain);
61 |
62 | Assert.assertFalse(HttpServletRequestWrapper.class.isAssignableFrom(filterChain.getRequest().getClass()));
63 | Assert.assertTrue(MockHttpServletRequest.class.isAssignableFrom(filterChain.getRequest().getClass()));
64 |
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/filter/NoopOrderedHiddenHttpMethodFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.filter;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Before;
5 | import org.junit.Test;
6 | import org.springframework.mock.env.MockEnvironment;
7 | import org.springframework.mock.web.MockFilterChain;
8 | import org.springframework.mock.web.MockFilterConfig;
9 | import org.springframework.mock.web.MockHttpServletRequest;
10 | import org.springframework.mock.web.MockHttpServletResponse;
11 |
12 | import javax.servlet.FilterChain;
13 | import javax.servlet.ServletException;
14 | import java.io.IOException;
15 |
16 | import static org.springframework.web.filter.OncePerRequestFilter.ALREADY_FILTERED_SUFFIX;
17 |
18 | /**
19 | * {@link com.alibaba.spring.web.filter.NoopHiddenHttpMethodFilter} Test
20 | *
21 | * @author Mercy
22 | * @see com.alibaba.spring.web.filter.NoopHiddenHttpMethodFilter
23 | * @since 2017.03.21
24 | */
25 | public class NoopOrderedHiddenHttpMethodFilterTest {
26 |
27 | private static final String FILTER_NAME = "test-filter";
28 |
29 | private static final String FILTERED_ATTRIBUTE_NAME = FILTER_NAME + ALREADY_FILTERED_SUFFIX;
30 |
31 | private MockEnvironment environment = new MockEnvironment();
32 |
33 | private MockFilterConfig filterConfig = new MockFilterConfig(FILTER_NAME);
34 |
35 | private MockHttpServletRequest request = new MockHttpServletRequest();
36 |
37 | private MockHttpServletResponse response = new MockHttpServletResponse();
38 |
39 | private FilterChain filterChain = new MockFilterChain();
40 |
41 | private NoopOrderedHiddenHttpMethodFilter filter = new NoopOrderedHiddenHttpMethodFilter();
42 |
43 | @Before
44 | public void init() throws ServletException {
45 |
46 | filter.init(filterConfig);
47 |
48 | filter.setEnvironment(environment);
49 |
50 | }
51 |
52 | @Test
53 | public void testShouldNotFilter() throws ServletException {
54 |
55 | filter.setEnvironment(environment);
56 |
57 | Assert.assertTrue(filter.shouldNotFilter(request));
58 |
59 | }
60 |
61 | @Test
62 | public void testOrder() {
63 |
64 | filter.setOrder(1);
65 |
66 | Assert.assertEquals(1, filter.getOrder());
67 |
68 | }
69 |
70 |
71 | @Test
72 | public void testDoFilter() throws ServletException, IOException {
73 |
74 | filter.doFilter(request, response, filterChain);
75 |
76 | Assert.assertNull(request.getAttribute(FILTERED_ATTRIBUTE_NAME));
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/filter/NoopOrderedHttpPutFormContentFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.filter;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Before;
5 | import org.junit.Test;
6 | import org.springframework.mock.env.MockEnvironment;
7 | import org.springframework.mock.web.MockFilterChain;
8 | import org.springframework.mock.web.MockFilterConfig;
9 | import org.springframework.mock.web.MockHttpServletRequest;
10 | import org.springframework.mock.web.MockHttpServletResponse;
11 |
12 | import javax.servlet.FilterChain;
13 | import javax.servlet.ServletException;
14 | import java.io.IOException;
15 |
16 | import static org.springframework.web.filter.OncePerRequestFilter.ALREADY_FILTERED_SUFFIX;
17 |
18 | /**
19 | * {@link NoopOrderedHttpPutFormContentFilter} Test
20 | *
21 | * @author Mercy
22 | * @see NoopOrderedHttpPutFormContentFilter
23 | * @since 2017.03.21
24 | */
25 | public class NoopOrderedHttpPutFormContentFilterTest {
26 |
27 | private static final String FILTER_NAME = "test-filter";
28 |
29 | private static final String FILTERED_ATTRIBUTE_NAME = FILTER_NAME + ALREADY_FILTERED_SUFFIX;
30 |
31 | private MockEnvironment environment = new MockEnvironment();
32 |
33 | private MockFilterConfig filterConfig = new MockFilterConfig(FILTER_NAME);
34 |
35 | private MockHttpServletRequest request = new MockHttpServletRequest();
36 |
37 | private MockHttpServletResponse response = new MockHttpServletResponse();
38 |
39 | private FilterChain filterChain = new MockFilterChain();
40 |
41 | private NoopOrderedHttpPutFormContentFilter filter = new NoopOrderedHttpPutFormContentFilter();
42 |
43 | @Before
44 | public void init() throws ServletException {
45 |
46 | filter.init(filterConfig);
47 |
48 | filter.setEnvironment(environment);
49 |
50 | }
51 |
52 | @Test
53 | public void testShouldNotFilter() throws ServletException {
54 |
55 | filter.setEnvironment(environment);
56 |
57 | Assert.assertTrue(filter.shouldNotFilter(request));
58 |
59 | }
60 |
61 | @Test
62 | public void testOrder() {
63 |
64 | filter.setOrder(1);
65 |
66 | Assert.assertEquals(1, filter.getOrder());
67 |
68 | }
69 |
70 |
71 | @Test
72 | public void testDoFilter() throws ServletException, IOException {
73 |
74 |
75 | filter.doFilter(request, response, filterChain);
76 |
77 | Assert.assertNull(request.getAttribute(FILTERED_ATTRIBUTE_NAME));
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/util/ViewResolverUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.util;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import static com.alibaba.boot.web.util.ViewResolverUtils.FREEMARKER_VIEW_RESOLVER_BEAN_NAME;
7 | import static com.alibaba.boot.web.util.ViewResolverUtils.GROOVY_MARKUP_VIEW_RESOLVER_BEAN_NAME;
8 | import static com.alibaba.boot.web.util.ViewResolverUtils.INTERNAL_RESOURCE_VIEW_RESOLVER_BEAN_NAME;
9 | import static com.alibaba.boot.web.util.ViewResolverUtils.MUSTACHE_VIEW_RESOLVER_BEAN_NAME;
10 | import static com.alibaba.boot.web.util.ViewResolverUtils.THYMELEAF_VIEW_RESOLVER_BEAN_NAME;
11 | import static com.alibaba.boot.web.util.ViewResolverUtils.VELOCITY_VIEW_RESOLVER_BEAN_NAME;
12 |
13 | /**
14 | * {@link ViewResolverUtils} Test
15 | *
16 | * @author Mercy
17 | * @see ViewResolverUtils
18 | * @since 2017.04.11
19 | */
20 | public class ViewResolverUtilsTest {
21 |
22 | @Test
23 | public void testConstants() {
24 |
25 | Assert.assertEquals("defaultViewResolver", INTERNAL_RESOURCE_VIEW_RESOLVER_BEAN_NAME);
26 | Assert.assertEquals("velocityViewResolver", VELOCITY_VIEW_RESOLVER_BEAN_NAME);
27 | Assert.assertEquals("thymeleafViewResolver", THYMELEAF_VIEW_RESOLVER_BEAN_NAME);
28 | Assert.assertEquals("freeMarkerViewResolver", FREEMARKER_VIEW_RESOLVER_BEAN_NAME);
29 | Assert.assertEquals("groovyMarkupViewResolver", GROOVY_MARKUP_VIEW_RESOLVER_BEAN_NAME);
30 | Assert.assertEquals("mustacheViewResolver", MUSTACHE_VIEW_RESOLVER_BEAN_NAME);
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/java/com/alibaba/boot/web/util/WebSupportUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.alibaba.boot.web.util;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import static com.alibaba.boot.web.util.WebSupportUtils.CONTENT_NEGOTIATION_MANAGER_PROPERTY_NAME_PREFIX;
7 | import static com.alibaba.boot.web.util.WebSupportUtils.NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME;
8 | import static com.alibaba.boot.web.util.WebSupportUtils.NOOP_HTTP_PUT_FORM_CONTENT_FILTER_ENABLED_PROPERTY_NAME;
9 | import static com.alibaba.boot.web.util.WebSupportUtils.PROPERTY_NAME_PREFIX;
10 | import static com.alibaba.boot.web.util.WebSupportUtils.VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME;
11 |
12 | /**
13 | * {@link WebSupportUtils} Test
14 | *
15 | * @author Mercy
16 | * @see WebSupportUtils
17 | * @since 2017.04.11
18 | */
19 | public class WebSupportUtilsTest {
20 |
21 | @Test
22 | public void testConstants() {
23 | Assert.assertEquals("web-support.", PROPERTY_NAME_PREFIX);
24 |
25 | Assert.assertEquals("web-support.content-negotiation-manager",
26 | CONTENT_NEGOTIATION_MANAGER_PROPERTY_NAME_PREFIX);
27 |
28 | Assert.assertEquals("web-support.exclusive-view-resolver",
29 | VIEW_RESOLVERS_EXCLUSIVE_BEAN_NAME_PROPERTY_NAME);
30 |
31 | Assert.assertEquals("web-support.noop.httpmethod.hiddenfilter.enabled",
32 | NOOP_HIDDEN_HTTP_METHOD_FILTER_ENABLED_PROPERTY_NAME);
33 |
34 | Assert.assertEquals("web-support.noop.formcontent.putfilter.enabled",
35 | NOOP_HTTP_PUT_FORM_CONTENT_FILTER_ENABLED_PROPERTY_NAME);
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/resources/application-disabled.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alibaba/spring-boot-support/15138e3c6bdbe14f22f1d89e32aae4c1b36ab021/spring-boot-web-support/src/test/resources/application-disabled.properties
--------------------------------------------------------------------------------
/spring-boot-web-support/src/test/resources/application-enabled.properties:
--------------------------------------------------------------------------------
1 | web-support.exclusive-view-resolver=thymeleafViewResolver
2 | # ContentNegotiationManager 配置项
3 | web-support.content-negotiation-manager.favorPathExtension=true
4 | web-support.content-negotiation-manager.favorParameter=true
5 | web-support.content-negotiation-manager.ignoreAcceptHeader=false
6 | web-support.content-negotiation-manager.useJaf=false
7 | web-support.content-negotiation-manager.parameterName=test-format
8 | web-support.content-negotiation-manager.mediaTypes.html=text/html
9 | web-support.content-negotiation-manager.mediaTypes.xml=text/xml
10 | web-support.content-negotiation-manager.mediaTypes.json=application/json
11 | web-support.content-negotiation-manager.mediaTypes.gif=image/gif
12 | web-support.content-negotiation-manager.mediaTypes.jpeg=image/jpeg
13 | web-support.content-negotiation-manager.defaultContentType=text/html
14 | # 激活 NoopOrderedHiddenHttpMethodFilter
15 | web-support.noop.httpmethod.hiddenfilter.enabled=true
16 | # 激活 NoopOrderedHttpPutFormContentFilter
17 | web-support.noop.formcontent.putfilter.enabled=true
--------------------------------------------------------------------------------