Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
xargs perl -p -i -e "s/[ \t]*$//g" {} \;
Issue: SPR-10127
This commit is contained in:
committed by
Chris Beams
parent
44a474a014
commit
1762157ad1
@@ -46,7 +46,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
* @see org.springframework.web.servlet.handler.SimpleServletHandlerAdapter
|
||||
*/
|
||||
public interface HandlerAdapter {
|
||||
|
||||
|
||||
/**
|
||||
* Given a handler instance, return whether or not this HandlerAdapter can
|
||||
* support it. Typical HandlerAdapters will base the decision on the handler
|
||||
@@ -58,8 +58,8 @@ public interface HandlerAdapter {
|
||||
* @param handler handler object to check
|
||||
* @return whether or not this object can use the given handler
|
||||
*/
|
||||
boolean supports(Object handler);
|
||||
|
||||
boolean supports(Object handler);
|
||||
|
||||
/**
|
||||
* Use the given handler to handle this request.
|
||||
* The workflow that is required may vary widely.
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class HttpServletBean extends HttpServlet
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set of required properties (Strings) that must be supplied as
|
||||
* config parameters to this servlet.
|
||||
*/
|
||||
@@ -230,7 +230,7 @@ public abstract class HttpServletBean extends HttpServlet
|
||||
*/
|
||||
public ServletConfigPropertyValues(ServletConfig config, Set<String> requiredProperties)
|
||||
throws ServletException {
|
||||
|
||||
|
||||
Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
|
||||
new HashSet<String>(requiredProperties) : null;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
/**
|
||||
* Simple servlet that can expose an internal resource, including a
|
||||
* Simple servlet that can expose an internal resource, including a
|
||||
* default URL if the specified resource is not found. An alternative,
|
||||
* for example, to trying and catching exceptions when using JSP include.
|
||||
*
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.web.servlet;
|
||||
|
||||
/**
|
||||
* Provides additional information about a View such as whether it
|
||||
* performs redirects.
|
||||
* Provides additional information about a View such as whether it
|
||||
* performs redirects.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -35,12 +35,12 @@ import java.util.Locale;
|
||||
*/
|
||||
public interface ViewResolver {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Resolve the given view by name.
|
||||
* <p>Note: To allow for ViewResolver chaining, a ViewResolver should
|
||||
* return <code>null</code> if a view with the given name is not defined in it.
|
||||
* However, this is not required: Some ViewResolvers will always attempt
|
||||
* to build View objects with the given name, unable to return <code>null</code>
|
||||
* to build View objects with the given name, unable to return <code>null</code>
|
||||
* (rather throwing an exception when View creation failed).
|
||||
* @param viewName name of the view to resolve
|
||||
* @param locale Locale in which to resolve the view.
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
|
||||
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
|
||||
|
||||
/**
|
||||
* {@link BeanDefinitionParser} that parses a {@code default-servlet-handler} element to
|
||||
* register a {@link DefaultServletHttpRequestHandler}. Will also register a
|
||||
* {@link SimpleUrlHandlerMapping} for mapping resource requests, and a
|
||||
* {@link HttpRequestHandlerAdapter}.
|
||||
*
|
||||
* {@link BeanDefinitionParser} that parses a {@code default-servlet-handler} element to
|
||||
* register a {@link DefaultServletHttpRequestHandler}. Will also register a
|
||||
* {@link SimpleUrlHandlerMapping} for mapping resource requests, and a
|
||||
* {@link HttpRequestHandlerAdapter}.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.0.4
|
||||
@@ -45,8 +45,8 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser
|
||||
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
|
||||
String defaultServletName = element.getAttribute("default-servlet-name");
|
||||
|
||||
String defaultServletName = element.getAttribute("default-servlet-name");
|
||||
RootBeanDefinition defaultServletHandlerDef = new RootBeanDefinition(DefaultServletHttpRequestHandler.class);
|
||||
defaultServletHandlerDef.setSource(source);
|
||||
defaultServletHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
@@ -56,20 +56,20 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser
|
||||
String defaultServletHandlerName = parserContext.getReaderContext().generateBeanName(defaultServletHandlerDef);
|
||||
parserContext.getRegistry().registerBeanDefinition(defaultServletHandlerName, defaultServletHandlerDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(defaultServletHandlerDef, defaultServletHandlerName));
|
||||
|
||||
|
||||
Map<String, String> urlMap = new ManagedMap<String, String>();
|
||||
urlMap.put("/**", defaultServletHandlerName);
|
||||
|
||||
|
||||
RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
|
||||
handlerMappingDef.setSource(source);
|
||||
handlerMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
|
||||
|
||||
|
||||
String handlerMappingBeanName = parserContext.getReaderContext().generateBeanName(handlerMappingDef);
|
||||
parserContext.getRegistry().registerBeanDefinition(handlerMappingBeanName, handlerMappingDef);
|
||||
parserContext.registerComponent(new BeanComponentDefinition(handlerMappingDef, handlerMappingBeanName));
|
||||
|
||||
// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
|
||||
|
||||
// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
|
||||
MvcNamespaceUtils.registerDefaultComponents(parserContext, source);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MvcNamespaceHandler extends NamespaceHandlerSupport {
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("default-servlet-handler", new DefaultServletHandlerBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("interceptors", new InterceptorsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("interceptors", new InterceptorsBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("resources", new ResourcesBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("view-controller", new ViewControllerBeanDefinitionParser());
|
||||
}
|
||||
|
||||
@@ -26,19 +26,19 @@ import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
|
||||
|
||||
/**
|
||||
* Convenience methods for use in MVC namespace BeanDefinitionParsers.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
abstract class MvcNamespaceUtils {
|
||||
|
||||
private static final String BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME =
|
||||
private static final String BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME =
|
||||
BeanNameUrlHandlerMapping.class.getName();
|
||||
|
||||
private static final String SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME =
|
||||
private static final String SIMPLE_CONTROLLER_HANDLER_ADAPTER_BEAN_NAME =
|
||||
SimpleControllerHandlerAdapter.class.getName();
|
||||
|
||||
private static final String HTTP_REQUEST_HANDLER_ADAPTER_BEAN_NAME =
|
||||
private static final String HTTP_REQUEST_HANDLER_ADAPTER_BEAN_NAME =
|
||||
HttpRequestHandlerAdapter.class.getName();
|
||||
|
||||
public static void registerDefaultComponents(ParserContext parserContext, Object source) {
|
||||
@@ -48,7 +48,7 @@ abstract class MvcNamespaceUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an {@link HttpRequestHandlerAdapter} under a well-known
|
||||
* Registers an {@link HttpRequestHandlerAdapter} under a well-known
|
||||
* name unless already registered.
|
||||
*/
|
||||
private static void registerBeanNameUrlHandlerMapping(ParserContext parserContext, Object source) {
|
||||
@@ -63,7 +63,7 @@ abstract class MvcNamespaceUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an {@link HttpRequestHandlerAdapter} under a well-known
|
||||
* Registers an {@link HttpRequestHandlerAdapter} under a well-known
|
||||
* name unless already registered.
|
||||
*/
|
||||
private static void registerHttpRequestHandlerAdapter(ParserContext parserContext, Object source) {
|
||||
@@ -75,9 +75,9 @@ abstract class MvcNamespaceUtils {
|
||||
parserContext.registerComponent(new BeanComponentDefinition(handlerAdapterDef, HTTP_REQUEST_HANDLER_ADAPTER_BEAN_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers a {@link SimpleControllerHandlerAdapter} under a well-known
|
||||
* Registers a {@link SimpleControllerHandlerAdapter} under a well-known
|
||||
* name unless already registered.
|
||||
*/
|
||||
private static void registerSimpleControllerHandlerAdapter(ParserContext parserContext, Object source) {
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class ViewControllerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
private static final String HANDLER_MAPPING_BEAN_NAME =
|
||||
private static final String HANDLER_MAPPING_BEAN_NAME =
|
||||
"org.springframework.web.servlet.config.viewControllerHandlerMapping";
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
// Register SimpleUrlHandlerMapping for view controllers
|
||||
BeanDefinition handlerMappingDef = registerHandlerMapping(parserContext, source);
|
||||
|
||||
// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
|
||||
// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
|
||||
MvcNamespaceUtils.registerDefaultComponents(parserContext, source);
|
||||
|
||||
// Create view controller bean definition
|
||||
RootBeanDefinition viewControllerDef = new RootBeanDefinition(ParameterizableViewController.class);
|
||||
viewControllerDef.setSource(source);
|
||||
if (element.hasAttribute("view-name")) {
|
||||
viewControllerDef.getPropertyValues().add("viewName", element.getAttribute("view-name"));
|
||||
viewControllerDef.getPropertyValues().add("viewName", element.getAttribute("view-name"));
|
||||
}
|
||||
Map<String, BeanDefinition> urlMap;
|
||||
if (handlerMappingDef.getPropertyValues().contains("urlMap")) {
|
||||
@@ -64,13 +64,13 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
else {
|
||||
urlMap = new ManagedMap<String, BeanDefinition>();
|
||||
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
|
||||
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
|
||||
}
|
||||
urlMap.put(element.getAttribute("path"), viewControllerDef);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private BeanDefinition registerHandlerMapping(ParserContext parserContext, Object source) {
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(HANDLER_MAPPING_BEAN_NAME)) {
|
||||
RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
|
||||
|
||||
@@ -29,9 +29,9 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
|
||||
|
||||
/**
|
||||
* Configures a request handler for serving static resources by forwarding the request to the Servlet container's
|
||||
* Configures a request handler for serving static resources by forwarding the request to the Servlet container's
|
||||
* "default" Servlet. This is intended to be used when the Spring MVC {@link DispatcherServlet} is mapped to "/"
|
||||
* thus overriding the Servlet container's default handling of static resources. Since this handler is configured
|
||||
* thus overriding the Servlet container's default handling of static resources. Since this handler is configured
|
||||
* at the lowest precedence, effectively it allows all other handler mappings to handle the request, and if none
|
||||
* of them do, this handler can forward it to the "default" Servlet.
|
||||
*
|
||||
@@ -57,7 +57,7 @@ public class DefaultServletHandlerConfigurer {
|
||||
|
||||
/**
|
||||
* Enable forwarding to the "default" Servlet. When this method is used the {@link DefaultServletHttpRequestHandler}
|
||||
* will try to auto-detect the "default" Servlet name. Alternatively, you can specify the name of the default
|
||||
* will try to auto-detect the "default" Servlet name. Alternatively, you can specify the name of the default
|
||||
* Servlet via {@link #enable(String)}.
|
||||
* @see DefaultServletHttpRequestHandler
|
||||
*/
|
||||
@@ -78,14 +78,14 @@ public class DefaultServletHandlerConfigurer {
|
||||
|
||||
/**
|
||||
* Return a handler mapping instance ordered at {@link Integer#MAX_VALUE} containing the
|
||||
* {@link DefaultServletHttpRequestHandler} instance mapped to {@code "/**"}; or {@code null} if
|
||||
* {@link DefaultServletHttpRequestHandler} instance mapped to {@code "/**"}; or {@code null} if
|
||||
* default servlet handling was not been enabled.
|
||||
*/
|
||||
protected AbstractHandlerMapping getHandlerMapping() {
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Map<String, HttpRequestHandler> urlMap = new HashMap<String, HttpRequestHandler>();
|
||||
urlMap.put("/**", handler);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.context.annotation.Import;
|
||||
/**
|
||||
* Add this annotation to an {@code @Configuration} class to have the Spring MVC
|
||||
* configuration defined in {@link WebMvcConfigurationSupport} imported:
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
* @EnableWebMvc
|
||||
@@ -33,9 +33,9 @@ import org.springframework.context.annotation.Import;
|
||||
* }
|
||||
* </pre>
|
||||
* <p>Customize the imported configuration by implementing the
|
||||
* {@link WebMvcConfigurer} interface or more likely by extending the
|
||||
* {@link WebMvcConfigurerAdapter} base class and overriding individual methods:
|
||||
*
|
||||
* {@link WebMvcConfigurer} interface or more likely by extending the
|
||||
* {@link WebMvcConfigurerAdapter} base class and overriding individual methods:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
* @EnableWebMvc
|
||||
@@ -56,11 +56,11 @@ import org.springframework.context.annotation.Import;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>If the customization options of {@link WebMvcConfigurer} do not expose
|
||||
* something you need to configure, consider removing the {@code @EnableWebMvc}
|
||||
* annotation and extending directly from {@link WebMvcConfigurationSupport}
|
||||
* <p>If the customization options of {@link WebMvcConfigurer} do not expose
|
||||
* something you need to configure, consider removing the {@code @EnableWebMvc}
|
||||
* annotation and extending directly from {@link WebMvcConfigurationSupport}
|
||||
* overriding selected {@code @Bean} methods:
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
* @ComponentScan(basePackageClasses = { MyConfiguration.class })
|
||||
|
||||
@@ -27,25 +27,25 @@ import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
/**
|
||||
* Encapsulates information required to create a resource handlers.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Keith Donald
|
||||
*
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public class ResourceHandlerRegistration {
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
|
||||
private final String[] pathPatterns;
|
||||
|
||||
|
||||
private final List<Resource> locations = new ArrayList<Resource>();
|
||||
|
||||
|
||||
private Integer cachePeriod;
|
||||
|
||||
/**
|
||||
* Create a {@link ResourceHandlerRegistration} instance.
|
||||
* @param resourceLoader a resource loader for turning a String location into a {@link Resource}
|
||||
* @param resourceLoader a resource loader for turning a String location into a {@link Resource}
|
||||
* @param pathPatterns one or more resource URL path patterns
|
||||
*/
|
||||
public ResourceHandlerRegistration(ResourceLoader resourceLoader, String... pathPatterns) {
|
||||
@@ -53,7 +53,7 @@ public class ResourceHandlerRegistration {
|
||||
this.resourceLoader = resourceLoader;
|
||||
this.pathPatterns = pathPatterns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add one or more resource locations from which to serve static content. Each location must point to a valid
|
||||
* directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked
|
||||
@@ -69,7 +69,7 @@ public class ResourceHandlerRegistration {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the cache period for the resources served by the resource handler, in seconds. The default is to not
|
||||
* send any cache headers but to rely on last-modified timestamps only. Set to 0 in order to send cache headers
|
||||
|
||||
@@ -32,15 +32,15 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
/**
|
||||
* Stores registrations of resource handlers for serving static resources such as images, css files and others
|
||||
* through Spring MVC including setting cache headers optimized for efficient loading in a web browser.
|
||||
* Stores registrations of resource handlers for serving static resources such as images, css files and others
|
||||
* through Spring MVC including setting cache headers optimized for efficient loading in a web browser.
|
||||
* Resources can be served out of locations under web application root, from the classpath, and others.
|
||||
*
|
||||
* <p>To create a resource handler, use {@link #addResourceHandler(String...)} providing the URL path patterns
|
||||
* <p>To create a resource handler, use {@link #addResourceHandler(String...)} providing the URL path patterns
|
||||
* for which the handler should be invoked to serve static resources (e.g. {@code "/resources/**"}).
|
||||
*
|
||||
* <p>Then use additional methods on the returned {@link ResourceHandlerRegistration} to add one or more
|
||||
* locations from which to serve static content from (e.g. {{@code "/"},
|
||||
* <p>Then use additional methods on the returned {@link ResourceHandlerRegistration} to add one or more
|
||||
* locations from which to serve static content from (e.g. {{@code "/"},
|
||||
* {@code "classpath:/META-INF/public-web-resources/"}}) or to specify a cache period for served resources.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -57,7 +57,7 @@ public class ResourceHandlerRegistry {
|
||||
private final List<ResourceHandlerRegistration> registrations = new ArrayList<ResourceHandlerRegistration>();
|
||||
|
||||
private int order = Integer.MAX_VALUE -1;
|
||||
|
||||
|
||||
public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext) {
|
||||
Assert.notNull(applicationContext, "ApplicationContext is required");
|
||||
this.applicationContext = applicationContext;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
|
||||
/**
|
||||
* Encapsulates information required to create a view controller.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Keith Donald
|
||||
* @since 3.1
|
||||
@@ -30,7 +30,7 @@ import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
||||
public class ViewControllerRegistration {
|
||||
|
||||
private final String urlPath;
|
||||
|
||||
|
||||
private String viewName;
|
||||
|
||||
/**
|
||||
@@ -41,11 +41,11 @@ public class ViewControllerRegistration {
|
||||
Assert.notNull(urlPath, "A URL path is required to create a view controller.");
|
||||
this.urlPath = urlPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the view name to use for this view controller. This field is optional. If not specified the
|
||||
* Sets the view name to use for this view controller. This field is optional. If not specified the
|
||||
* view controller will return a {@code null} view name, which will be resolved through the configured
|
||||
* {@link RequestToViewNameTranslator}. By default that means "/foo/bar" would resolve to "foo/bar".
|
||||
* {@link RequestToViewNameTranslator}. By default that means "/foo/bar" would resolve to "foo/bar".
|
||||
*/
|
||||
public void setViewName(String viewName) {
|
||||
this.viewName = viewName;
|
||||
@@ -66,5 +66,5 @@ public class ViewControllerRegistration {
|
||||
controller.setViewName(viewName);
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
|
||||
/**
|
||||
* Stores registrations of view controllers. A view controller does nothing more than return a specified
|
||||
* view name. It saves you from having to write a controller when you want to forward the request straight
|
||||
* Stores registrations of view controllers. A view controller does nothing more than return a specified
|
||||
* view name. It saves you from having to write a controller when you want to forward the request straight
|
||||
* through to a view such as a JSP.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
public class ViewControllerRegistry {
|
||||
|
||||
private final List<ViewControllerRegistration> registrations = new ArrayList<ViewControllerRegistration>();
|
||||
|
||||
|
||||
private int order = 1;
|
||||
|
||||
public ViewControllerRegistration addViewController(String urlPath) {
|
||||
@@ -45,10 +45,10 @@ public class ViewControllerRegistry {
|
||||
registrations.add(registration);
|
||||
return registration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the order to use for ViewControllers mappings relative to other {@link HandlerMapping}s
|
||||
* configured in the Spring MVC application context. The default value for view controllers is 1,
|
||||
* Specify the order to use for ViewControllers mappings relative to other {@link HandlerMapping}s
|
||||
* configured in the Spring MVC application context. The default value for view controllers is 1,
|
||||
* which is 1 higher than the value used for annotated controllers.
|
||||
*/
|
||||
public void setOrder(int order) {
|
||||
@@ -67,11 +67,11 @@ public class ViewControllerRegistry {
|
||||
for (ViewControllerRegistration registration : registrations) {
|
||||
urlMap.put(registration.getUrlPath(), registration.getViewController());
|
||||
}
|
||||
|
||||
|
||||
SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
|
||||
handlerMapping.setOrder(order);
|
||||
handlerMapping.setUrlMap(urlMap);
|
||||
return handlerMapping;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @since 3.0.1
|
||||
*/
|
||||
public class ConversionServiceExposingInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of exception resolvers to delegate to.
|
||||
* Set the list of exception resolvers to delegate to.
|
||||
*/
|
||||
public void setExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
|
||||
this.resolvers = exceptionResolvers;
|
||||
@@ -61,7 +61,7 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the exception by iterating over the list of configured exception resolvers.
|
||||
* Resolve the exception by iterating over the list of configured exception resolvers.
|
||||
* The first one to return a ModelAndView instance wins. Otherwise {@code null} is returned.
|
||||
*/
|
||||
public ModelAndView resolveException(HttpServletRequest request,
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SimpleServletHandlerAdapter implements HandlerAdapter {
|
||||
|
||||
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
|
||||
|
||||
((Servlet) handler).service(request, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @see BeanNameUrlHandlerMapping
|
||||
*/
|
||||
public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
|
||||
|
||||
|
||||
private final Map<String, Object> urlMap = new HashMap<String, Object>();
|
||||
|
||||
|
||||
|
||||
@@ -45,5 +45,5 @@ public class AcceptHeaderLocaleResolver implements LocaleResolver {
|
||||
throw new UnsupportedOperationException(
|
||||
"Cannot change HTTP accept header - use a different locale resolution strategy");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SessionLocaleResolver extends AbstractLocaleResolver {
|
||||
* @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
|
||||
*/
|
||||
public static final String LOCALE_SESSION_ATTRIBUTE_NAME = SessionLocaleResolver.class.getName() + ".LOCALE";
|
||||
|
||||
|
||||
|
||||
public Locale resolveLocale(HttpServletRequest request) {
|
||||
Locale locale = (Locale) WebUtils.getSessionAttribute(request, LOCALE_SESSION_ATTRIBUTE_NAME);
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.web.util.WebUtils;
|
||||
/**
|
||||
* <p>Convenient superclass for controller implementations, using the Template
|
||||
* Method design pattern.</p>
|
||||
*
|
||||
*
|
||||
* <p>As stated in the {@link org.springframework.web.servlet.mvc.Controller Controller}
|
||||
* interface, a lot of functionality is already provided by certain abstract
|
||||
* base controllers. The AbstractController is one of the most important
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractController extends WebContentGenerator implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return handleRequestInternal(request, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* gets applied to populate the new form object with initial request parameters and the
|
||||
* {@link #onBindOnNewForm(HttpServletRequest, Object, BindException)} callback method is
|
||||
* called. <em>Note:</em> any defined Validators are not applied at this point, to allow
|
||||
* partial binding. However be aware that any Binder customizations applied via
|
||||
* partial binding. However be aware that any Binder customizations applied via
|
||||
* initBinder() (such as
|
||||
* {@link org.springframework.validation.DataBinder#setRequiredFields(String[])} will
|
||||
* still apply. As such, if using bindOnNewForm=true and initBinder() customizations are
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
* JavaBeans based on request parameters, validate the content of such
|
||||
* JavaBeans using {@link org.springframework.validation.Validator Validators}
|
||||
* and use custom editors (in the form of
|
||||
* {@link java.beans.PropertyEditor PropertyEditors}) to transform
|
||||
* {@link java.beans.PropertyEditor PropertyEditors}) to transform
|
||||
* objects into strings and vice versa, for example. Three notions are mentioned here:</p>
|
||||
*
|
||||
* <p><b>Command class:</b><br>
|
||||
@@ -50,7 +50,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
* Upon receiving a request, any BaseCommandController will attempt to fill the
|
||||
* command object using the request parameters. This is done using the typical
|
||||
* and well-known JavaBeans property notation. When a request parameter named
|
||||
* <code>'firstName'</code> exists, the framework will attempt to call
|
||||
* <code>'firstName'</code> exists, the framework will attempt to call
|
||||
* <code>setFirstName([value])</code> passing the value of the parameter. Nested properties
|
||||
* are of course supported. For instance a parameter named <code>'address.city'</code>
|
||||
* will result in a <code>getAddress().setCity([value])</code> call on the
|
||||
|
||||
@@ -68,7 +68,7 @@ import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
* @author Keith Donald
|
||||
*/
|
||||
public class ParameterizableViewController extends AbstractController {
|
||||
|
||||
|
||||
private String viewName;
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ServletForwardingController extends AbstractController implements B
|
||||
private String servletName;
|
||||
|
||||
private String beanName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the name of the servlet to forward to,
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
/**
|
||||
* Simple <code>Controller</code> implementation that transforms the virtual
|
||||
* path of a URL into a view name and returns that view.
|
||||
*
|
||||
*
|
||||
* <p>Can optionally prepend a {@link #setPrefix prefix} and/or append a
|
||||
* {@link #setSuffix suffix} to build the viewname from the URL filename.
|
||||
*
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.web.servlet.mvc.condition;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Supports "name=value" style expressions as described in:
|
||||
* {@link org.springframework.web.bind.annotation.RequestMapping#params()} and
|
||||
* Supports "name=value" style expressions as described in:
|
||||
* {@link org.springframework.web.bind.annotation.RequestMapping#params()} and
|
||||
* {@link org.springframework.web.bind.annotation.RequestMapping#headers()}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -48,7 +48,7 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
this.value = parseValue(expression.substring(separator + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A base class for {@link RequestCondition} types providing implementations of
|
||||
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
||||
*
|
||||
* A base class for {@link RequestCondition} types providing implementations of
|
||||
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>> implements RequestCondition<T> {
|
||||
|
||||
|
||||
/**
|
||||
* Return the discrete items a request condition is composed of.
|
||||
* For example URL patterns, HTTP request methods, param expressions, etc.
|
||||
* @return a collection of objects, never {@code null}
|
||||
*/
|
||||
protected abstract Collection<?> getContent();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -26,13 +26,13 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* A logical conjunction (' && ') request condition that matches a request against
|
||||
* A logical conjunction (' && ') request condition that matches a request against
|
||||
* a set of header expressions with syntax defined in {@link RequestMapping#headers()}.
|
||||
*
|
||||
* <p>Expressions passed to the constructor with header names 'Accept' or
|
||||
*
|
||||
* <p>Expressions passed to the constructor with header names 'Accept' or
|
||||
* 'Content-Type' are ignored. See {@link ConsumesRequestCondition} and
|
||||
* {@link ProducesRequestCondition} for those.
|
||||
*
|
||||
* {@link ProducesRequestCondition} for those.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
@@ -42,20 +42,20 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
private final Set<HeaderExpression> expressions;
|
||||
|
||||
/**
|
||||
* Create a new instance from the given header expressions. Expressions with
|
||||
* header names 'Accept' or 'Content-Type' are ignored. See {@link ConsumesRequestCondition}
|
||||
* and {@link ProducesRequestCondition} for those.
|
||||
* Create a new instance from the given header expressions. Expressions with
|
||||
* header names 'Accept' or 'Content-Type' are ignored. See {@link ConsumesRequestCondition}
|
||||
* and {@link ProducesRequestCondition} for those.
|
||||
* @param headers media type expressions with syntax defined in {@link RequestMapping#headers()};
|
||||
* if 0, the condition will match to every request.
|
||||
*/
|
||||
public HeadersRequestCondition(String... headers) {
|
||||
this(parseExpressions(headers));
|
||||
}
|
||||
|
||||
|
||||
private HeadersRequestCondition(Collection<HeaderExpression> conditions) {
|
||||
this.expressions = Collections.unmodifiableSet(new LinkedHashSet<HeaderExpression>(conditions));
|
||||
}
|
||||
|
||||
|
||||
private static Collection<HeaderExpression> parseExpressions(String... headers) {
|
||||
Set<HeaderExpression> expressions = new LinkedHashSet<HeaderExpression>();
|
||||
if (headers != null) {
|
||||
@@ -76,7 +76,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
public Set<NameValueExpression<String>> getExpressions() {
|
||||
return new LinkedHashSet<NameValueExpression<String>>(this.expressions);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Collection<HeaderExpression> getContent() {
|
||||
return this.expressions;
|
||||
@@ -88,7 +88,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance with the union of the header expressions
|
||||
* Returns a new instance with the union of the header expressions
|
||||
* from "this" and the "other" instance.
|
||||
*/
|
||||
public HeadersRequestCondition combine(HeadersRequestCondition other) {
|
||||
@@ -96,9 +96,9 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
set.addAll(other.expressions);
|
||||
return new HeadersRequestCondition(set);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns "this" instance if the request matches all expressions;
|
||||
* Returns "this" instance if the request matches all expressions;
|
||||
* or {@code null} otherwise.
|
||||
*/
|
||||
public HeadersRequestCondition getMatchingCondition(HttpServletRequest request) {
|
||||
@@ -116,10 +116,10 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
* <li>0 if the two conditions have the same number of header expressions
|
||||
* <li>Less than 0 if "this" instance has more header expressions
|
||||
* <li>Greater than 0 if the "other" instance has more header expressions
|
||||
* </ul>
|
||||
*
|
||||
* <p>It is assumed that both instances have been obtained via
|
||||
* {@link #getMatchingCondition(HttpServletRequest)} and each instance
|
||||
* </ul>
|
||||
*
|
||||
* <p>It is assumed that both instances have been obtained via
|
||||
* {@link #getMatchingCondition(HttpServletRequest)} and each instance
|
||||
* contains the matching header expression only or is otherwise empty.
|
||||
*/
|
||||
public int compareTo(HeadersRequestCondition other, HttpServletRequest request) {
|
||||
@@ -127,7 +127,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and matches a single header expression to a request.
|
||||
* Parses and matches a single header expression to a request.
|
||||
*/
|
||||
static class HeaderExpression extends AbstractNameValueExpression<String> {
|
||||
|
||||
@@ -157,5 +157,5 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
result = 31 * result + (isNegated ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* A contract for media type expressions (e.g. "text/plain", "!text/plain") as
|
||||
* defined in the {@code @RequestMapping} annotation for "consumes" and
|
||||
* A contract for media type expressions (e.g. "text/plain", "!text/plain") as
|
||||
* defined in the {@code @RequestMapping} annotation for "consumes" and
|
||||
* "produces" conditions.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*
|
||||
*
|
||||
* @see RequestMapping#consumes()
|
||||
* @see RequestMapping#produces()
|
||||
*/
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
||||
/**
|
||||
* A contract for {@code "name!=value"} style expression used to specify request
|
||||
* A contract for {@code "name!=value"} style expression used to specify request
|
||||
* parameters and request header conditions in {@code @RequestMapping}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*
|
||||
*
|
||||
* @see RequestMapping#params()
|
||||
* @see RequestMapping#headers()
|
||||
*/
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* A logical conjunction (' && ') request condition that matches a request against
|
||||
* a set parameter expressions with syntax defined in {@link RequestMapping#params()}.
|
||||
*
|
||||
* A logical conjunction (' && ') request condition that matches a request against
|
||||
* a set parameter expressions with syntax defined in {@link RequestMapping#params()}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
@@ -37,16 +37,16 @@ import org.springframework.web.util.WebUtils;
|
||||
public final class ParamsRequestCondition extends AbstractRequestCondition<ParamsRequestCondition> {
|
||||
|
||||
private final Set<ParamExpression> expressions;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance from the given param expressions.
|
||||
* @param params expressions with syntax defined in {@link RequestMapping#params()};
|
||||
* Create a new instance from the given param expressions.
|
||||
* @param params expressions with syntax defined in {@link RequestMapping#params()};
|
||||
* if 0, the condition will match to every request.
|
||||
*/
|
||||
public ParamsRequestCondition(String... params) {
|
||||
this(parseExpressions(params));
|
||||
}
|
||||
|
||||
|
||||
private ParamsRequestCondition(Collection<ParamExpression> conditions) {
|
||||
this.expressions = Collections.unmodifiableSet(new LinkedHashSet<ParamExpression>(conditions));
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance with the union of the param expressions
|
||||
* Returns a new instance with the union of the param expressions
|
||||
* from "this" and the "other" instance.
|
||||
*/
|
||||
public ParamsRequestCondition combine(ParamsRequestCondition other) {
|
||||
@@ -89,7 +89,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns "this" instance if the request matches all param expressions;
|
||||
* Returns "this" instance if the request matches all param expressions;
|
||||
* or {@code null} otherwise.
|
||||
*/
|
||||
public ParamsRequestCondition getMatchingCondition(HttpServletRequest request) {
|
||||
@@ -107,10 +107,10 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
* <li>0 if the two conditions have the same number of parameter expressions
|
||||
* <li>Less than 0 if "this" instance has more parameter expressions
|
||||
* <li>Greater than 0 if the "other" instance has more parameter expressions
|
||||
* </ul>
|
||||
*
|
||||
* <p>It is assumed that both instances have been obtained via
|
||||
* {@link #getMatchingCondition(HttpServletRequest)} and each instance
|
||||
* </ul>
|
||||
*
|
||||
* <p>It is assumed that both instances have been obtained via
|
||||
* {@link #getMatchingCondition(HttpServletRequest)} and each instance
|
||||
* contains the matching parameter expressions only or is otherwise empty.
|
||||
*/
|
||||
public int compareTo(ParamsRequestCondition other, HttpServletRequest request) {
|
||||
@@ -118,7 +118,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and matches a single param expression to a request.
|
||||
* Parses and matches a single param expression to a request.
|
||||
*/
|
||||
static class ParamExpression extends AbstractNameValueExpression<String> {
|
||||
|
||||
|
||||
@@ -67,5 +67,5 @@ public interface RequestCondition<T> {
|
||||
* to ensure they have content relevant to current request only.
|
||||
*/
|
||||
int compareTo(T other, HttpServletRequest request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.support.WebContentGenerator;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link HandlerAdapter} implementations that support
|
||||
* Abstract base class for {@link HandlerAdapter} implementations that support
|
||||
* handlers of type {@link HandlerMethod}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc} <p>This implementation expects the handler to be an {@link HandlerMethod}.
|
||||
*
|
||||
@@ -85,9 +85,9 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
|
||||
*
|
||||
* @param request current HTTP request
|
||||
* @param response current HTTP response
|
||||
* @param handlerMethod handler method to use. This object must have previously been passed to the
|
||||
* @param handlerMethod handler method to use. This object must have previously been passed to the
|
||||
* {@link #supportsInternal(HandlerMethod)} this interface, which must have returned {@code true}.
|
||||
* @return ModelAndView object with the name of the view and the required model data, or {@code null} if
|
||||
* @return ModelAndView object with the name of the view and the required model data, or {@code null} if
|
||||
* the request has been handled directly
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondit
|
||||
* <li>{@link ProducesRequestCondition}
|
||||
* <li>{@code RequestCondition<?>} (optional, custom request condition)
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
@@ -56,7 +56,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
private final ConsumesRequestCondition consumesCondition;
|
||||
|
||||
private final ProducesRequestCondition producesCondition;
|
||||
|
||||
|
||||
private final RequestConditionHolder customConditionHolder;
|
||||
|
||||
private int hash;
|
||||
@@ -65,9 +65,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
* Creates a new instance with the given request conditions.
|
||||
*/
|
||||
public RequestMappingInfo(PatternsRequestCondition patterns,
|
||||
RequestMethodsRequestCondition methods,
|
||||
RequestMethodsRequestCondition methods,
|
||||
ParamsRequestCondition params,
|
||||
HeadersRequestCondition headers,
|
||||
HeadersRequestCondition headers,
|
||||
ConsumesRequestCondition consumes,
|
||||
ProducesRequestCondition produces,
|
||||
RequestCondition<?> custom) {
|
||||
@@ -89,7 +89,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL patterns of this {@link RequestMappingInfo};
|
||||
* Returns the URL patterns of this {@link RequestMappingInfo};
|
||||
* or instance with 0 patterns, never {@code null}
|
||||
*/
|
||||
public PatternsRequestCondition getPatternsCondition() {
|
||||
@@ -97,7 +97,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP request methods of this {@link RequestMappingInfo};
|
||||
* Returns the HTTP request methods of this {@link RequestMappingInfo};
|
||||
* or instance with 0 request methods, never {@code null}
|
||||
*/
|
||||
public RequestMethodsRequestCondition getMethodsCondition() {
|
||||
@@ -161,9 +161,9 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all conditions in this request mapping info match the provided request and returns
|
||||
* a potentially new request mapping info with conditions tailored to the current request.
|
||||
* <p>For example the returned instance may contain the subset of URL patterns that match to
|
||||
* Checks if all conditions in this request mapping info match the provided request and returns
|
||||
* a potentially new request mapping info with conditions tailored to the current request.
|
||||
* <p>For example the returned instance may contain the subset of URL patterns that match to
|
||||
* the current request, sorted with best matching patterns on top.
|
||||
* @return a new instance in case all conditions match; or {@code null} otherwise
|
||||
*/
|
||||
@@ -173,27 +173,27 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
HeadersRequestCondition headers = headersCondition.getMatchingCondition(request);
|
||||
ConsumesRequestCondition consumes = consumesCondition.getMatchingCondition(request);
|
||||
ProducesRequestCondition produces = producesCondition.getMatchingCondition(request);
|
||||
|
||||
|
||||
if (methods == null || params == null || headers == null || consumes == null || produces == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
PatternsRequestCondition patterns = patternsCondition.getMatchingCondition(request);
|
||||
if (patterns == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
RequestConditionHolder custom = customConditionHolder.getMatchingCondition(request);
|
||||
if (custom == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new RequestMappingInfo(patterns, methods, params, headers, consumes, produces, custom.getCondition());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares "this" info (i.e. the current instance) with another info in the context of a request.
|
||||
* <p>Note: it is assumed both instances have been obtained via
|
||||
* Compares "this" info (i.e. the current instance) with another info in the context of a request.
|
||||
* <p>Note: it is assumed both instances have been obtained via
|
||||
* {@link #getMatchingCondition(HttpServletRequest)} to ensure they have conditions with
|
||||
* content relevant to current request.
|
||||
*/
|
||||
@@ -241,7 +241,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||
this.paramsCondition.equals(other.paramsCondition) &&
|
||||
this.headersCondition.equals(other.headersCondition) &&
|
||||
this.consumesCondition.equals(other.consumesCondition) &&
|
||||
this.producesCondition.equals(other.producesCondition) &&
|
||||
this.producesCondition.equals(other.producesCondition) &&
|
||||
this.customConditionHolder.equals(other.customConditionHolder));
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -52,9 +52,9 @@ import org.springframework.web.servlet.mvc.annotation.ModelAndViewResolver;
|
||||
* @since 3.1
|
||||
*/
|
||||
public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMethodReturnValueHandler {
|
||||
|
||||
|
||||
private final List<ModelAndViewResolver> mavResolvers;
|
||||
|
||||
|
||||
private final ModelAttributeMethodProcessor modelAttributeProcessor = new ModelAttributeMethodProcessor(true);
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class ModelAndViewResolverMethodReturnValueHandler implements HandlerMeth
|
||||
}
|
||||
|
||||
// No suitable ModelAndViewResolver..
|
||||
|
||||
|
||||
if (this.modelAttributeProcessor.supportsReturnType(returnType)) {
|
||||
this.modelAttributeProcessor.handleReturnValue(returnValue, returnType, mavContainer, request);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
||||
|
||||
private final List<String> fileExtensions = new ArrayList<String>();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Whether to use suffix pattern match (".*") when matching patterns to
|
||||
* requests. If enabled a method mapped to "/users" also matches to "/users.*".
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.web.util.WebUtils;
|
||||
/**
|
||||
* An {@link org.springframework.web.method.annotation.AbstractCookieValueMethodArgumentResolver} that resolves cookie
|
||||
* values from an {@link HttpServletRequest}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
|
||||
return super.createAttribute(attributeName, parameter, binderFactory, request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain a value from the request that may be used to instantiate the
|
||||
* model attribute through type conversion from String to the target type.
|
||||
@@ -140,7 +140,7 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>Downcast {@link WebDataBinder} to {@link ServletRequestDataBinder} before binding.
|
||||
|
||||
@@ -71,12 +71,12 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
|
||||
MethodParameter parameter, ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
|
||||
throws IOException {
|
||||
|
||||
|
||||
Class<?> paramType = parameter.getParameterType();
|
||||
if (WebRequest.class.isAssignableFrom(paramType)) {
|
||||
return webRequest;
|
||||
}
|
||||
|
||||
|
||||
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
|
||||
if (ServletRequest.class.isAssignableFrom(paramType) || MultipartRequest.class.isAssignableFrom(paramType)) {
|
||||
Object nativeRequest = webRequest.getNativeRequest(paramType);
|
||||
@@ -107,5 +107,5 @@ public class ServletRequestMethodArgumentResolver implements HandlerMethodArgume
|
||||
throw new UnsupportedOperationException("Unknown parameter type: " + paramType + " in method: " + method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -89,5 +89,5 @@ public class ServletResponseMethodArgumentResolver implements HandlerMethodArgum
|
||||
throw new UnsupportedOperationException("Unknown parameter type: " + paramType + " in method: " + method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import org.springframework.web.method.annotation.AbstractWebArgumentResolverAdap
|
||||
/**
|
||||
* A Servlet-specific {@link org.springframework.web.method.annotation.AbstractWebArgumentResolverAdapter} that creates a
|
||||
* {@link NativeWebRequest} from {@link ServletRequestAttributes}.
|
||||
*
|
||||
*
|
||||
* <p><strong>Note:</strong> This class is provided for backwards compatibility.
|
||||
* However it is recommended to re-write a {@code WebArgumentResolver} as
|
||||
* {@code HandlerMethodArgumentResolver}. For more details see javadoc of
|
||||
* However it is recommended to re-write a {@code WebArgumentResolver} as
|
||||
* {@code HandlerMethodArgumentResolver}. For more details see javadoc of
|
||||
* {@link org.springframework.web.method.annotation.AbstractWebArgumentResolverAdapter}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
* @see MultiActionController#setMethodNameResolver
|
||||
*/
|
||||
public interface MethodNameResolver {
|
||||
|
||||
|
||||
/**
|
||||
* Return a method name that can handle this request. Such
|
||||
* mappings are typically, but not necessarily, based on URL.
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.web.util.WebUtils;
|
||||
/**
|
||||
* Implementation of {@link MethodNameResolver} which supports several strategies
|
||||
* for mapping parameter values to the names of methods to invoke.
|
||||
*
|
||||
*
|
||||
* <p>The simplest strategy looks for a specific named parameter, whose value is
|
||||
* considered the name of the method to invoke. The name of the parameter may be
|
||||
* specified as a JavaBean property, if the default <code>action</code> is not
|
||||
* acceptable.
|
||||
*
|
||||
*
|
||||
* <p>The alternative strategy uses the very existence of a request parameter (
|
||||
* i.e. a request parameter with a certain name is found) as an indication that a
|
||||
* method with the same name should be dispatched to. In this case, the actual
|
||||
@@ -47,18 +47,18 @@ import org.springframework.web.util.WebUtils;
|
||||
* button should be set to the mapped method name, while the 'value' attribute
|
||||
* is normally displayed as the button label by the browser, and will be
|
||||
* ignored by the resolver.
|
||||
*
|
||||
*
|
||||
* <p>Note that the second strategy also supports the use of submit buttons of
|
||||
* type 'image'. That is, an image submit button named 'reset' will normally be
|
||||
* submitted by the browser as two request paramters called 'reset.x', and
|
||||
* 'reset.y'. When checking for the existence of a paramter from the
|
||||
* 'reset.y'. When checking for the existence of a paramter from the
|
||||
* <code>methodParamNames</code> list, to indicate that a specific method should
|
||||
* be called, the code will look for request parameter in the "reset" form
|
||||
* (exactly as spcified in the list), and in the "reset.x" form ('.x' appended to
|
||||
* the name in the list). In this way it can handle both normal and image submit
|
||||
* buttons. The actual method name resolved if there is a match will always be
|
||||
* the bare form without the ".x".
|
||||
*
|
||||
* the bare form without the ".x".
|
||||
*
|
||||
* <p><b>Note:</b> If both strategies are configured, i.e. both "paramName"
|
||||
* and "methodParamNames" are specified, then both will be checked for any given
|
||||
* request. A match for an explicit request parameter in the "methodParamNames"
|
||||
@@ -66,7 +66,7 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* <p>For use with either strategy, the name of a default handler method to use
|
||||
* when there is no match, can be specified as a JavaBean property.
|
||||
*
|
||||
*
|
||||
* <p>For both resolution strategies, the method name is of course coming from
|
||||
* some sort of view code, (such as a JSP page). While this may be acceptable,
|
||||
* it is sometimes desireable to treat this only as a 'logical' method name,
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.util.PathMatcher;
|
||||
*/
|
||||
public class PropertiesMethodNameResolver extends AbstractUrlMethodNameResolver
|
||||
implements InitializingBean {
|
||||
|
||||
|
||||
private Properties mappings;
|
||||
|
||||
private PathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
* at <i>method</i> rather than <i>class</i> level. This is useful when
|
||||
* we want to avoid having many trivial controller classes, as can
|
||||
* easily happen when using an MVC framework.
|
||||
*
|
||||
*
|
||||
* <p>Typically a controller that handles multiple request types will
|
||||
* extend MultiActionController, and implement multiple request handling
|
||||
* methods that will be invoked by reflection if they follow this class'
|
||||
* naming convention. Classes are analyzed at startup and methods cached,
|
||||
* so the performance overhead of reflection in this approach is negligible.
|
||||
*
|
||||
*
|
||||
* <p>This approach is analogous to the Struts 1.1 <b>DispatcherAction</b>
|
||||
* class, but more sophisticated, as it supports configurable mapping from
|
||||
* requests to URLs and allows for delegation as well as subclassing.
|
||||
*
|
||||
* <p>This package is discussed in Chapter 12 of <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
|
||||
*
|
||||
* <p>This package is discussed in Chapter 12 of <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
|
||||
* by Rod Johnson, and used in the sample application.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* with Spring. Provides both abstract base classes and concrete implementations
|
||||
* for often seen use cases.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* A <code>Controller</code> - as defined in this package - is analogous to a Struts
|
||||
* <code>Action</code>. Usually <code>Controllers</code> are JavaBeans
|
||||
@@ -18,7 +18,7 @@
|
||||
* independent of the view, PDF views are possible, as well as for instance Excel
|
||||
* views.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* How to actually set up a (web)application using the MVC framework Spring
|
||||
* provides is explained in more detail in the
|
||||
@@ -29,7 +29,7 @@
|
||||
* workflow of some of the abstract and concrete controller and how to extend
|
||||
* and fully use their functionality.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Especially useful to read, while getting into the Spring MVC framework
|
||||
* are the following:
|
||||
|
||||
@@ -24,17 +24,17 @@ import org.springframework.web.servlet.FlashMap;
|
||||
|
||||
/**
|
||||
* A specialization of the {@link Model} interface that controllers can use to
|
||||
* select attributes for a redirect scenario. Since the intent of adding
|
||||
* redirect attributes is very explicit -- i.e. to be used for a redirect URL,
|
||||
* attribute values may be formatted as Strings and stored that way to make
|
||||
* them eligible to be appended to the query string or expanded as URI
|
||||
* select attributes for a redirect scenario. Since the intent of adding
|
||||
* redirect attributes is very explicit -- i.e. to be used for a redirect URL,
|
||||
* attribute values may be formatted as Strings and stored that way to make
|
||||
* them eligible to be appended to the query string or expanded as URI
|
||||
* variables in {@code org.springframework.web.servlet.view.RedirectView}.
|
||||
*
|
||||
* <p>This interface also provides a way to add flash attributes. For a
|
||||
* general overview of flash attributes see {@link FlashMap}. You can use
|
||||
* {@link RedirectAttributes} to store flash attributes and they will be
|
||||
* automatically propagated to the "output" FlashMap of the current request.
|
||||
*
|
||||
*
|
||||
* <p>This interface also provides a way to add flash attributes. For a
|
||||
* general overview of flash attributes see {@link FlashMap}. You can use
|
||||
* {@link RedirectAttributes} to store flash attributes and they will be
|
||||
* automatically propagated to the "output" FlashMap of the current request.
|
||||
*
|
||||
* <p>Example usage in an {@code @Controller}:
|
||||
* <pre>
|
||||
* @RequestMapping(value = "/accounts", method = RequestMethod.POST)
|
||||
@@ -47,13 +47,13 @@ import org.springframework.web.servlet.FlashMap;
|
||||
* return "redirect:/accounts/{id}";
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>A RedirectAttributes model is empty when the method is called and is never
|
||||
* used unless the method returns a redirect view name or a RedirectView.
|
||||
*
|
||||
*
|
||||
* <p>After the redirect, flash attributes are automatically added to the model
|
||||
* of the controller that serves the target URL.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
@@ -64,11 +64,11 @@ public interface RedirectAttributes extends Model {
|
||||
RedirectAttributes addAttribute(Object attributeValue);
|
||||
|
||||
RedirectAttributes addAllAttributes(Collection<?> attributeValues);
|
||||
|
||||
|
||||
RedirectAttributes mergeAttributes(Map<String, ?> attributes);
|
||||
|
||||
/**
|
||||
* Add the given flash attribute.
|
||||
* Add the given flash attribute.
|
||||
* @param attributeName the attribute name; never {@code null}
|
||||
* @param attributeValue the attribute value; may be {@code null}
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ public interface RedirectAttributes extends Model {
|
||||
|
||||
/**
|
||||
* Add the given flash storage using a
|
||||
* {@link org.springframework.core.Conventions#getVariableName generated name}.
|
||||
* {@link org.springframework.core.Conventions#getVariableName generated name}.
|
||||
* @param attributeValue the flash attribute value; never {@code null}
|
||||
*/
|
||||
RedirectAttributes addFlashAttribute(Object attributeValue);
|
||||
|
||||
@@ -24,10 +24,10 @@ import org.springframework.validation.DataBinder;
|
||||
|
||||
/**
|
||||
* A {@link ModelMap} implementation of {@link RedirectAttributes} that formats
|
||||
* values as Strings using a {@link DataBinder}. Also provides a place to store
|
||||
* flash attributes so they can survive a redirect without the need to be
|
||||
* values as Strings using a {@link DataBinder}. Also provides a place to store
|
||||
* flash attributes so they can survive a redirect without the need to be
|
||||
* embedded in the redirect URL.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
@@ -45,9 +45,9 @@ public class RedirectAttributesModelMap extends ModelMap implements RedirectAttr
|
||||
public RedirectAttributesModelMap(DataBinder dataBinder) {
|
||||
this.dataBinder = dataBinder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor without a DataBinder.
|
||||
* Default constructor without a DataBinder.
|
||||
* Attribute values are converted to String via {@link #toString()}.
|
||||
*/
|
||||
public RedirectAttributesModelMap() {
|
||||
@@ -153,7 +153,7 @@ public class RedirectAttributesModelMap extends ModelMap implements RedirectAttr
|
||||
this.flashAttributes.addAttribute(attributeName, attributeValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public RedirectAttributes addFlashAttribute(Object attributeValue) {
|
||||
this.flashAttributes.addAttribute(attributeValue);
|
||||
return this;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Provides servlets that integrate with the application context
|
||||
* infrastructure, and the core interfaces and classes for the
|
||||
* Spring web MVC framework.
|
||||
*
|
||||
*
|
||||
* <p>This package and related packages are discussed in Chapters 12 and 13 of
|
||||
* <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
|
||||
* by Rod Johnson (Wrox, 2002).
|
||||
|
||||
@@ -231,7 +231,7 @@ public class RequestContext {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the fallback locale for this context. <p>The default implementation checks for a JSTL locale attribute
|
||||
* in request, session or application scope; if not found, returns the <code>HttpServletRequest.getLocale()</code>.
|
||||
|
||||
@@ -158,9 +158,9 @@ public abstract class RequestContextUtils {
|
||||
|
||||
/**
|
||||
* Return a read-only {@link Map} with "input" flash attributes saved on a
|
||||
* previous request.
|
||||
* previous request.
|
||||
* @param request the current request
|
||||
* @return a read-only Map, or {@code null}
|
||||
* @return a read-only Map, or {@code null}
|
||||
* @see FlashMap
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -22,17 +22,17 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* A contract for inspecting and potentially modifying request data values such
|
||||
* as URL query parameters or form field values before they are rendered by a
|
||||
* as URL query parameters or form field values before they are rendered by a
|
||||
* view or before a redirect.
|
||||
*
|
||||
* <p>Implementations may use this contract for example as part of a solution
|
||||
* to provide data integrity, confidentiality, protection against cross-site
|
||||
*
|
||||
* <p>Implementations may use this contract for example as part of a solution
|
||||
* to provide data integrity, confidentiality, protection against cross-site
|
||||
* request forgery (CSRF), and others or for other tasks such as automatically
|
||||
* adding a hidden field to all forms and URLs.
|
||||
*
|
||||
*
|
||||
* <p>View technologies that support this contract can obtain an instance to
|
||||
* delegate to via {@link RequestContext#getRequestDataValueProcessor()}.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Support classes for Spring's web MVC framework.
|
||||
* Provides easy evaluation of the request context in views,
|
||||
* and miscellaneous HandlerInterceptor implementations.
|
||||
* and miscellaneous HandlerInterceptor implementations.
|
||||
*
|
||||
*/
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
@@ -147,7 +147,7 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
private ConversionService getConversionService(PageContext pageContext) {
|
||||
return (ConversionService) pageContext.getRequest().getAttribute(ConversionService.class.getName());
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class EvalTag extends HtmlEscapingAwareTag {
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
private Object resolveImplicitVariable(String name) throws AccessException {
|
||||
if (this.variableResolver == null) {
|
||||
return null;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -68,9 +68,9 @@ public class MessageTag extends HtmlEscapingAwareTag {
|
||||
private String argumentSeparator = DEFAULT_ARGUMENT_SEPARATOR;
|
||||
|
||||
private String text;
|
||||
|
||||
|
||||
private String var;
|
||||
|
||||
|
||||
private String scope = TagUtils.SCOPE_PAGE;
|
||||
|
||||
private boolean javaScriptEscape = false;
|
||||
@@ -118,7 +118,7 @@ public class MessageTag extends HtmlEscapingAwareTag {
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set PageContext attribute name under which to expose
|
||||
* a variable that contains the resolved message.
|
||||
@@ -128,7 +128,7 @@ public class MessageTag extends HtmlEscapingAwareTag {
|
||||
public void setVar(String var) {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the scope to export the variable to.
|
||||
* Default is SCOPE_PAGE ("page").
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -19,10 +19,10 @@ package org.springframework.web.servlet.tags;
|
||||
/**
|
||||
* Bean used to pass name-value pair parameters from a {@link ParamTag} to a
|
||||
* {@link ParamAware} tag.
|
||||
*
|
||||
* <p>Attributes are the raw values passed to the spring:param tag and have not
|
||||
* been encoded or escaped.
|
||||
*
|
||||
*
|
||||
* <p>Attributes are the raw values passed to the spring:param tag and have not
|
||||
* been encoded or escaped.
|
||||
*
|
||||
* @author Scott Andrews
|
||||
* @since 3.0
|
||||
* @see ParamTag
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2008 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -22,9 +22,9 @@ import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
/**
|
||||
* JSP tag for collecting name-value parameters and passing them to a
|
||||
* {@link ParamAware} ancestor in the tag hierarchy.
|
||||
*
|
||||
*
|
||||
* <p>This tag must be nested under a param aware tag.
|
||||
*
|
||||
*
|
||||
* @author Scott Andrews
|
||||
* @since 3.0
|
||||
* @see Param
|
||||
@@ -69,10 +69,10 @@ public class ParamTag extends BodyTagSupport {
|
||||
|
||||
/**
|
||||
* Sets the name of the parameter
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Required
|
||||
*
|
||||
*
|
||||
* @param name the parameter name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
@@ -81,10 +81,10 @@ public class ParamTag extends BodyTagSupport {
|
||||
|
||||
/**
|
||||
* Sets the value of the parameter
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Optional. If not set, the tag's body content is evaluated
|
||||
*
|
||||
*
|
||||
* @param value the parameter value
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.web.servlet.support.RequestContext;
|
||||
|
||||
/**
|
||||
* Superclass for all tags that require a {@link RequestContext}.
|
||||
*
|
||||
*
|
||||
* <p>The <code>RequestContext</code> instance provides easy access
|
||||
* to current state like the
|
||||
* {@link org.springframework.web.context.WebApplicationContext},
|
||||
@@ -54,7 +54,7 @@ public abstract class RequestContextAwareTag extends TagSupport implements TryCa
|
||||
public static final String REQUEST_CONTEXT_PAGE_ATTRIBUTE =
|
||||
"org.springframework.web.servlet.tags.REQUEST_CONTEXT";
|
||||
|
||||
|
||||
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
||||
@@ -40,37 +40,37 @@ import org.springframework.web.util.UriUtils;
|
||||
/**
|
||||
* JSP tag for creating URLs. Modeled after the JSTL c:url tag with backwards
|
||||
* compatibility in mind.
|
||||
*
|
||||
*
|
||||
* <p>Enhancements to the JSTL functionality include:
|
||||
* <ul>
|
||||
* <li>URL encoded template URI variables</li>
|
||||
* <li>HTML/XML escaping of URLs</li>
|
||||
* <li>JavaScript escaping of URLs</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p>Template URI variables are indicated in the {@link #setValue(String) 'value'}
|
||||
* attribute and marked by braces '{variableName}'. The braces and attribute name are
|
||||
* replaced by the URL encoded value of a parameter defined with the spring:param tag
|
||||
* in the body of the url tag. If no parameter is available the literal value is
|
||||
* passed through. Params matched to template variables will not be added to the query
|
||||
* replaced by the URL encoded value of a parameter defined with the spring:param tag
|
||||
* in the body of the url tag. If no parameter is available the literal value is
|
||||
* passed through. Params matched to template variables will not be added to the query
|
||||
* string.
|
||||
*
|
||||
* <p>Use of the spring:param tag for URI template variables is strongly recommended
|
||||
* over direct EL substitution as the values are URL encoded. Failure to properly
|
||||
*
|
||||
* <p>Use of the spring:param tag for URI template variables is strongly recommended
|
||||
* over direct EL substitution as the values are URL encoded. Failure to properly
|
||||
* encode URL can leave an application vulnerable to XSS and other injection attacks.
|
||||
*
|
||||
* <p>URLs can be HTML/XML escaped by setting the {@link #setHtmlEscape(String)
|
||||
* 'htmlEscape'} attribute to 'true'. Detects an HTML escaping setting, either on
|
||||
* this tag instance, the page level, or the <code>web.xml</code> level. The default
|
||||
*
|
||||
* <p>URLs can be HTML/XML escaped by setting the {@link #setHtmlEscape(String)
|
||||
* 'htmlEscape'} attribute to 'true'. Detects an HTML escaping setting, either on
|
||||
* this tag instance, the page level, or the <code>web.xml</code> level. The default
|
||||
* is 'false'. When setting the URL value into a variable, escaping is not recommended.
|
||||
*
|
||||
*
|
||||
* <p>Example usage:
|
||||
* <pre><spring:url value="/url/path/{variableName}">
|
||||
* <spring:param name="variableName" value="more than JSTL c:url" />
|
||||
* </spring:url></pre>
|
||||
* Results in:
|
||||
* <code>/currentApplicationContext/url/path/more%20than%20JSTL%20c%3Aurl</code>
|
||||
*
|
||||
*
|
||||
* @author Scott Andrews
|
||||
* @since 3.0
|
||||
* @see ParamTag
|
||||
@@ -171,13 +171,13 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
String url = createUrl();
|
||||
|
||||
|
||||
RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
|
||||
ServletRequest request = this.pageContext.getRequest();
|
||||
if ((processor != null) && (request instanceof HttpServletRequest)) {
|
||||
url = processor.processUrl((HttpServletRequest) request, url);
|
||||
}
|
||||
|
||||
|
||||
if (this.var == null) {
|
||||
// print the url to the writer
|
||||
try {
|
||||
@@ -229,7 +229,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||
// HTML and/or JavaScript escape, if demanded.
|
||||
urlStr = isHtmlEscape() ? HtmlUtils.htmlEscape(urlStr) : urlStr;
|
||||
urlStr = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(urlStr) : urlStr;
|
||||
|
||||
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class AbstractCheckedElementTag extends AbstractHtmlInputElement
|
||||
protected boolean isValidDynamicAttribute(String localName, Object value) {
|
||||
return !"type".equals(localName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the type of the HTML input element to generate:
|
||||
* "checkbox" or "radio".
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* Convenient super class for many html tags that render content using the databinding
|
||||
* features of the {@link AbstractHtmlElementTag AbstractHtmlElementTag}. The only thing sub tags
|
||||
* need to do is override {@link #renderDefaultContent(TagWriter)}.
|
||||
* need to do is override {@link #renderDefaultContent(TagWriter)}.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -29,13 +29,13 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* Base class for databinding-aware JSP tags that render HTML element. Provides
|
||||
* a set of properties corresponding to the set of HTML attributes that are common
|
||||
* across elements.
|
||||
*
|
||||
* <p>Additionally, this base class allows for rendering non-standard attributes
|
||||
* as part of the tag's output. These attributes are accessible to subclasses if
|
||||
* needed via the {@link AbstractHtmlElementTag#getDynamicAttributes() dynamicAttributes}
|
||||
* across elements.
|
||||
*
|
||||
* <p>Additionally, this base class allows for rendering non-standard attributes
|
||||
* as part of the tag's output. These attributes are accessible to subclasses if
|
||||
* needed via the {@link AbstractHtmlElementTag#getDynamicAttributes() dynamicAttributes}
|
||||
* map.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Jeremy Grelle
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||
private String onkeyup;
|
||||
|
||||
private String onkeydown;
|
||||
|
||||
|
||||
private Map<String, Object> dynamicAttributes;
|
||||
|
||||
|
||||
@@ -383,14 +383,14 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||
protected String getOnkeydown() {
|
||||
return this.onkeydown;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the map of dynamic attributes.
|
||||
* Get the map of dynamic attributes.
|
||||
*/
|
||||
protected Map<String, Object> getDynamicAttributes() {
|
||||
return this.dynamicAttributes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -404,7 +404,7 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||
}
|
||||
dynamicAttributes.put(localName, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the given name-value pair is a valid dynamic attribute.
|
||||
*/
|
||||
@@ -445,7 +445,7 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
|
||||
writeOptionalAttribute(tagWriter, ONKEYPRESS_ATTRIBUTE, getOnkeypress());
|
||||
writeOptionalAttribute(tagWriter, ONKEYUP_ATTRIBUTE, getOnkeyup());
|
||||
writeOptionalAttribute(tagWriter, ONKEYDOWN_ATTRIBUTE, getOnkeydown());
|
||||
|
||||
|
||||
if (!CollectionUtils.isEmpty(this.dynamicAttributes)) {
|
||||
for (String attr : this.dynamicAttributes.keySet()) {
|
||||
tagWriter.writeOptionalAttributeValue(attr, getDisplayString(this.dynamicAttributes.get(attr)));
|
||||
|
||||
@@ -162,7 +162,7 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
|
||||
/**
|
||||
* Gets the value of the '<code>readonly</code>' attribute.
|
||||
* May be a runtime expression.
|
||||
* @see #isReadonly()
|
||||
* @see #isReadonly()
|
||||
*/
|
||||
protected String getReadonly() {
|
||||
return this.readonly;
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
|
||||
if (itemsObject == null && boundType != null && boundType.isEnum()) {
|
||||
itemsObject = boundType.getEnumConstants();
|
||||
}
|
||||
|
||||
|
||||
if (itemsObject == null) {
|
||||
throw new IllegalArgumentException("Attribute 'items' is required and must be a Collection, an Array or a Map");
|
||||
}
|
||||
@@ -241,10 +241,10 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
|
||||
Object renderValue;
|
||||
if (valueProperty != null) {
|
||||
renderValue = wrapper.getPropertyValue(valueProperty);
|
||||
}
|
||||
}
|
||||
else if (item instanceof Enum) {
|
||||
renderValue = ((Enum<?>) item).name();
|
||||
}
|
||||
}
|
||||
else {
|
||||
renderValue = item;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.servlet.jsp.JspException;
|
||||
import org.springframework.web.servlet.support.RequestDataValueProcessor;
|
||||
|
||||
/**
|
||||
* An HTML button tag. This tag is provided for completeness if the application
|
||||
* An HTML button tag. This tag is provided for completeness if the application
|
||||
* relies on a {@link RequestDataValueProcessor}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -38,7 +38,7 @@ public class ButtonTag extends AbstractHtmlElementTag {
|
||||
private TagWriter tagWriter;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
private String disabled;
|
||||
@@ -63,21 +63,21 @@ public class ButtonTag extends AbstractHtmlElementTag {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value of the '<code>value</code>' attribute.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of the '<code>disabled</code>' attribute.
|
||||
*/
|
||||
public String getDisabled() {
|
||||
return this.disabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value of the '<code>disabled</code>' attribute.
|
||||
* May be a runtime expression.
|
||||
|
||||
@@ -48,7 +48,7 @@ public class HiddenInputTag extends AbstractHtmlElementTag {
|
||||
public String getDisabled() {
|
||||
return this.disabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value of the '<code>disabled</code>' attribute.
|
||||
* May be a runtime expression.
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.servlet.jsp.JspException;
|
||||
/**
|
||||
* Data-binding-aware JSP tag for rendering an HTML '<code>input</code>'
|
||||
* element with a '<code>type</code>' of '<code>text</code>'.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -172,7 +172,7 @@ public class InputTag extends AbstractHtmlInputElementTag {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags {@code type="checkbox"} and {@code type="radio"} as illegal
|
||||
* Flags {@code type="checkbox"} and {@code type="radio"} as illegal
|
||||
* dynamic attributes.
|
||||
*/
|
||||
@Override
|
||||
@@ -184,7 +184,7 @@ public class InputTag extends AbstractHtmlInputElementTag {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of the '<code>type</code>' attribute. Subclasses
|
||||
* can override this to change the type of '<code>input</code>' element
|
||||
|
||||
@@ -62,7 +62,7 @@ public class LabelTag extends AbstractHtmlElementTag {
|
||||
/**
|
||||
* Set the value of the '<code>for</code>' attribute.
|
||||
* <p>Defaults to the value of {@link #getPath}; may be a runtime expression.
|
||||
* @throws IllegalArgumentException if the supplied value is <code>null</code>
|
||||
* @throws IllegalArgumentException if the supplied value is <code>null</code>
|
||||
*/
|
||||
public void setFor(String forId) {
|
||||
Assert.notNull(forId, "'forId' must not be null");
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.springframework.web.util.TagUtils;
|
||||
|
||||
/**
|
||||
* JSP tag for rendering an HTML '<code>option</code>' tag.
|
||||
*
|
||||
*
|
||||
* <p><b>Must be used nested inside a {@link SelectTag}.</b>
|
||||
*
|
||||
*
|
||||
* <p>Provides full support for databinding by marking an
|
||||
* '<code>option</code>' as 'selected' if the {@link #setValue value}
|
||||
* matches the value bound to the out {@link SelectTag}.
|
||||
@@ -67,7 +67,7 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
* The name of the '<code>value</code>' attribute.
|
||||
*/
|
||||
private static final String VALUE_ATTRIBUTE = VALUE_VARIABLE_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* The name of the '<code>disabled</code>' attribute.
|
||||
*/
|
||||
@@ -87,7 +87,7 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
private Object oldValue;
|
||||
|
||||
private Object oldDisplayValue;
|
||||
|
||||
|
||||
private String disabled;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
protected Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value of the '<code>disabled</code>' attribute.
|
||||
* <p>May be a runtime expression.
|
||||
@@ -121,10 +121,10 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
protected String getDisabled() {
|
||||
return this.disabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is the current HTML tag disabled?
|
||||
* @return <code>true</code> if this tag is disabled
|
||||
* @return <code>true</code> if this tag is disabled
|
||||
*/
|
||||
protected boolean isDisabled() throws JspException {
|
||||
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
|
||||
@@ -239,7 +239,7 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
private void assertUnderSelectTag() {
|
||||
TagUtils.assertHasAncestorOfType(this, SelectTag.class, "option", "select");
|
||||
}
|
||||
|
||||
|
||||
private SelectTag getSelectTag() {
|
||||
return (SelectTag) findAncestorWithClass(this, SelectTag.class);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.servlet.support.RequestContext;
|
||||
* the <code>labelProperty</code>). These properties are then used when
|
||||
* rendering each element of the array/{@link Collection} as an '<code>option</code>'.
|
||||
* If either property name is omitted, the value of {@link Object#toString()} of
|
||||
* the corresponding array/{@link Collection} element is used instead. However,
|
||||
* the corresponding array/{@link Collection} element is used instead. However,
|
||||
* if the item is an enum, {@link Enum#name()} is used as the default value.
|
||||
* </p>
|
||||
* <h3>Using a {@link Map}:</h3>
|
||||
@@ -228,7 +228,7 @@ class OptionWriter {
|
||||
|
||||
String valueDisplayString = getDisplayString(value);
|
||||
String labelDisplayString = getDisplayString(label);
|
||||
|
||||
|
||||
valueDisplayString = processOptionValue(valueDisplayString);
|
||||
|
||||
// allows render values to handle some strange browser compat issues.
|
||||
@@ -254,13 +254,13 @@ class OptionWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the option value before it is written.
|
||||
* The default implementation simply returns the same value unchanged.
|
||||
* Process the option value before it is written.
|
||||
* The default implementation simply returns the same value unchanged.
|
||||
*/
|
||||
protected String processOptionValue(String resolvedValue) {
|
||||
return resolvedValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the supplied values matched the selected value.
|
||||
* Delegates to {@link SelectedValueComparator#isSelected}.
|
||||
|
||||
@@ -29,16 +29,16 @@ import org.springframework.web.util.TagUtils;
|
||||
* Convenient tag that allows one to supply a collection of objects
|
||||
* that are to be rendered as '<code>option</code>' tags within a
|
||||
* '<code>select</code>' tag.
|
||||
*
|
||||
*
|
||||
* <p><i>Must</i> be used within a {@link SelectTag 'select' tag}.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Scott Andrews
|
||||
* @since 2.0
|
||||
*/
|
||||
public class OptionsTag extends AbstractHtmlElementTag {
|
||||
|
||||
|
||||
/**
|
||||
* The {@link java.util.Collection}, {@link java.util.Map} or array of
|
||||
* objects used to generate the inner '<code>option</code>' tags.
|
||||
@@ -200,8 +200,8 @@ public class OptionsTag extends AbstractHtmlElementTag {
|
||||
* Inner class that adapts OptionWriter for multiple options to be rendered.
|
||||
*/
|
||||
private class OptionsWriter extends OptionWriter {
|
||||
|
||||
private final String selectName;
|
||||
|
||||
private final String selectName;
|
||||
|
||||
public OptionsWriter(String selectName, Object optionSource, String valueProperty, String labelProperty) {
|
||||
super(optionSource, getBindStatus(), valueProperty, labelProperty, isHtmlEscape());
|
||||
@@ -223,7 +223,7 @@ public class OptionsTag extends AbstractHtmlElementTag {
|
||||
protected String processOptionValue(String value) {
|
||||
return processFieldValue(this.selectName, value, "option");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import javax.servlet.jsp.JspException;
|
||||
*
|
||||
* <p>A typical usage pattern will involved multiple tag instances bound
|
||||
* to the same property but with different values.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
|
||||
@@ -312,5 +312,5 @@ public class SelectTag extends AbstractHtmlInputElementTag {
|
||||
this.tagWriter = null;
|
||||
this.pageContext.removeAttribute(LIST_VALUE_PAGE_ATTRIBUTE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ import org.springframework.web.servlet.support.BindStatus;
|
||||
* inequality, logical (String-representation-based) equality and {@link PropertyEditor}-based comparison.
|
||||
*
|
||||
* <p>Full support is provided for comparing arrays, {@link Collection Collections} and {@link Map Maps}.
|
||||
*
|
||||
*
|
||||
* <p><h1><a name="equality-contract">Equality Contract</a></h1>
|
||||
* For single-valued objects equality is first tested using standard {@link Object#equals Java equality}. As
|
||||
* such, user code should endeavour to implement {@link Object#equals} to speed up the comparison process. If
|
||||
* {@link Object#equals} returns <code>false</code> then an attempt is made at an
|
||||
* {@link #exhaustiveCompare exhaustive comparison} with the aim being to <strong>prove</strong> equality rather
|
||||
* than disprove it.
|
||||
*
|
||||
*
|
||||
* <p>Special support is given for instances of {@link LabeledEnum} with a <code>String</code>-based
|
||||
* comparison of the candidate value against the code of the {@link LabeledEnum}. This can be useful when a
|
||||
* {@link LabeledEnum} is used to define a list of '<code><option></code>' elements in HTML.
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.servlet.support.BindStatus;
|
||||
* <p>Next, an attempt is made to compare the <code>String</code> representations of both the candidate and bound
|
||||
* values. This may result in <code>true</code> in a number of cases due to the fact both values will be represented
|
||||
* as <code>Strings</code> when shown to the user.
|
||||
*
|
||||
*
|
||||
* <p>Next, if the candidate value is a <code>String</code>, an attempt is made to compare the bound value to
|
||||
* result of applying the corresponding {@link PropertyEditor} to the candidate. This comparison may be
|
||||
* executed twice, once against the direct <code>String</code> instances, and then against the <code>String</code>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
* Theme support classes for Spring's web MVC framework.
|
||||
* Provides standard ThemeResolver implementations,
|
||||
* and a HandlerInterceptor for theme changes.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>If you don't provide a bean of one of these classes as <code>themeResolver</code>,
|
||||
* <li>If you don't provide a bean of one of these classes as <code>themeResolver</code>,
|
||||
* a <code>FixedThemeResolver</code> will be provided with the default theme name 'theme'.</li>
|
||||
* <li>If you use a defined <code>FixedThemeResolver</code>, you will able to use another theme
|
||||
* <li>If you use a defined <code>FixedThemeResolver</code>, you will able to use another theme
|
||||
* name for default, but the users will stick on this theme.</li>
|
||||
* <li>With a <code>CookieThemeResolver</code> or <code>SessionThemeResolver</code>, you can allow
|
||||
* the user to change his current theme.</li>
|
||||
* <li>Generally, you will put in the themes resource bundles the paths of CSS files, images and HTML constructs.</li>
|
||||
* <li>For retrieving themes data, you can either use the spring:theme tag in JSP or access via the
|
||||
* <li>For retrieving themes data, you can either use the spring:theme tag in JSP or access via the
|
||||
* <code>RequestContext</code> for other view technologies.</li>
|
||||
* <li>The <code>pagedlist</code> demo application uses themes</li>
|
||||
* </ul>
|
||||
|
||||
@@ -160,7 +160,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu
|
||||
*/
|
||||
public void removeFromCache(String viewName, Locale locale) {
|
||||
if (!isCache()) {
|
||||
logger.warn("View caching is SWITCHED OFF -- removal not necessary");
|
||||
logger.warn("View caching is SWITCHED OFF -- removal not necessary");
|
||||
}
|
||||
else {
|
||||
Object cacheKey = getCacheKey(viewName, locale);
|
||||
@@ -173,7 +173,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No cached instance for view '" + cacheKey + "' was found");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Cache for view " + cacheKey + " has been cleared");
|
||||
|
||||
@@ -54,13 +54,13 @@ import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* <p>View that redirects to an absolute, context relative, or current request
|
||||
* relative URL. The URL may be a URI template in which case the URI template
|
||||
* variables will be replaced with values available in the model. By default
|
||||
* all primitive model attributes (or collections thereof) are exposed as HTTP
|
||||
* query parameters (assuming they've not been used as URI template variables),
|
||||
* but this behavior can be changed by overriding the
|
||||
* relative URL. The URL may be a URI template in which case the URI template
|
||||
* variables will be replaced with values available in the model. By default
|
||||
* all primitive model attributes (or collections thereof) are exposed as HTTP
|
||||
* query parameters (assuming they've not been used as URI template variables),
|
||||
* but this behavior can be changed by overriding the
|
||||
* {@link #isEligibleProperty(String, Object)} method.
|
||||
*
|
||||
*
|
||||
* <p>A URL for this view is supposed to be a HTTP redirect URL, i.e.
|
||||
* suitable for HttpServletResponse's <code>sendRedirect</code> method, which
|
||||
* is what actually does the redirect if the HTTP 1.0 flag is on, or via sending
|
||||
@@ -262,7 +262,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
|
||||
String targetUrl = createTargetUrl(model, request);
|
||||
targetUrl = updateTargetUrl(targetUrl, model, request, response);
|
||||
|
||||
|
||||
FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
|
||||
if (!CollectionUtils.isEmpty(flashMap)) {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(targetUrl).build();
|
||||
@@ -277,13 +277,13 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the target URL by checking if the redirect string is a URI template first,
|
||||
* expanding it with the given model, and then optionally appending simple type model
|
||||
* Creates the target URL by checking if the redirect string is a URI template first,
|
||||
* expanding it with the given model, and then optionally appending simple type model
|
||||
* attributes as query String parameters.
|
||||
*/
|
||||
protected final String createTargetUrl(Map<String, Object> model, HttpServletRequest request)
|
||||
throws UnsupportedEncodingException {
|
||||
|
||||
|
||||
// Prepare target URL.
|
||||
StringBuilder targetUrl = new StringBuilder();
|
||||
if (this.contextRelative && getUrl().startsWith("/")) {
|
||||
@@ -304,7 +304,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
Map<String, String> variables = getCurrentRequestUriVariables(request);
|
||||
targetUrl = replaceUriTemplateVariables(targetUrl.toString(), model, variables, enc);
|
||||
}
|
||||
|
||||
|
||||
if (this.exposeModelAttributes) {
|
||||
appendQueryProperties(targetUrl, model, enc);
|
||||
}
|
||||
@@ -313,9 +313,9 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace URI template variables in the target URL with encoded model
|
||||
* Replace URI template variables in the target URL with encoded model
|
||||
* attributes or URI variables from the current request. Model attributes
|
||||
* referenced in the URL are removed from the model.
|
||||
* referenced in the URL are removed from the model.
|
||||
* @param targetUrl the redirect URL
|
||||
* @param model Map that contains model attributes
|
||||
* @param currentUriVariables current request URI variables to use
|
||||
@@ -325,7 +325,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
protected StringBuilder replaceUriTemplateVariables(
|
||||
String targetUrl, Map<String, Object> model, Map<String, String> currentUriVariables, String encodingScheme)
|
||||
throws UnsupportedEncodingException {
|
||||
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
Matcher m = URI_TEMPLATE_VARIABLE_PATTERN.matcher(targetUrl);
|
||||
int endLastMatch = 0;
|
||||
@@ -343,11 +343,11 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, String> getCurrentRequestUriVariables(HttpServletRequest request) {
|
||||
Map<String, String> uriVars =
|
||||
Map<String, String> uriVars =
|
||||
(Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
return (uriVars != null) ? uriVars : Collections.<String, String> emptyMap();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Append query properties to the redirect URL.
|
||||
* Stringifies, URL-encodes and formats model attributes as query properties.
|
||||
@@ -503,9 +503,9 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
* it to update the redirect target URL.
|
||||
* @return the updated URL or the same as URL as the one passed in
|
||||
*/
|
||||
protected String updateTargetUrl(String targetUrl, Map<String, Object> model,
|
||||
protected String updateTargetUrl(String targetUrl, Map<String, Object> model,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
|
||||
RequestContext requestContext = null;
|
||||
if (getWebApplicationContext() != null) {
|
||||
requestContext = createRequestContext(request, response, model);
|
||||
@@ -523,10 +523,10 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
targetUrl = processor.processUrl(request, targetUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return targetUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a redirect back to the HTTP client
|
||||
* @param request current HTTP request (allows for reacting to request method)
|
||||
@@ -540,7 +540,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
throws IOException {
|
||||
|
||||
String encodedRedirectURL = response.encodeRedirectURL(targetUrl);
|
||||
|
||||
|
||||
if (http10Compatible) {
|
||||
if (this.statusCode != null) {
|
||||
response.setStatus(this.statusCode.value());
|
||||
|
||||
@@ -36,10 +36,10 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.servlet.View;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.web.servlet.ViewResolver} implementation
|
||||
* {@link org.springframework.web.servlet.ViewResolver} implementation
|
||||
* that uses bean definitions in a {@link ResourceBundle}, specified by
|
||||
* the bundle basename.
|
||||
*
|
||||
*
|
||||
* <p>The bundle is typically defined in a properties file, located in
|
||||
* the class path. The default bundle basename is "views".
|
||||
*
|
||||
|
||||
@@ -341,13 +341,13 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
||||
/**
|
||||
* Whether views resolved by this resolver should add path variables the model or not.
|
||||
* The default setting is to allow each View decide (see {@link AbstractView#setExposePathVariables(boolean)}.
|
||||
* However, you can use this property to override that.
|
||||
* However, you can use this property to override that.
|
||||
* @param exposePathVariables
|
||||
* <ul>
|
||||
* <li>{@code true} - all Views resolved by this resolver will expose path variables
|
||||
* <li>{@code false} - no Views resolved by this resolver will expose path variables
|
||||
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
|
||||
* <ul>
|
||||
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
|
||||
* <ul>
|
||||
* @see AbstractView#setExposePathVariables(boolean)
|
||||
*/
|
||||
public void setExposePathVariables(Boolean exposePathVariables) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
/**
|
||||
* Convenient superclass for Excel document views.
|
||||
*
|
||||
*
|
||||
* <p>This class uses the <i>JExcelAPI</i> instead of <i>POI</i>. More
|
||||
* information on <i>JExcelAPI</i> can be found on their <a
|
||||
* href="http://www.andykhan.com/jexcelapi/" target="_blank">website</a>.
|
||||
@@ -43,19 +43,19 @@ import org.springframework.web.servlet.view.AbstractView;
|
||||
* <li>url (optional): The url of an existing Excel document to pick as a
|
||||
* starting point. It is done without localization part nor the .xls extension.
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p>The file will be searched with locations in the following order:
|
||||
* <ul>
|
||||
* <li>[url]_[language]_[country].xls
|
||||
* <li>[url]_[language].xls
|
||||
* <li>[url].xls
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p>For working with the workbook in the subclass, see <a
|
||||
* href="http://www.andykhan.com/jexcelapi/">Java Excel API site</a>
|
||||
*
|
||||
*
|
||||
* <p>As an example, you can try this snippet:
|
||||
*
|
||||
*
|
||||
* <pre class="code">
|
||||
* protected void buildExcelDocument(
|
||||
* Map<String, Object> model, WritableWorkbook workbook,
|
||||
@@ -64,15 +64,15 @@ import org.springframework.web.servlet.view.AbstractView;
|
||||
* if (workbook.getNumberOfSheets() == 0) {
|
||||
* workbook.createSheet("Spring", 0);
|
||||
* }
|
||||
*
|
||||
*
|
||||
* WritableSheet sheet = workbook.getSheet("Spring");
|
||||
* Label label = new Label(0, 0, "This is a nice label");
|
||||
* sheet.addCell(label);
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* The use of this view is close to the AbstractExcelView class,
|
||||
* just using the JExcel API instead of the Apache POI API.
|
||||
*
|
||||
*
|
||||
* @author Bram Smeets
|
||||
* @author Alef Arendsen
|
||||
* @author Juergen Hoeller
|
||||
@@ -120,7 +120,7 @@ public abstract class AbstractJExcelView extends AbstractView {
|
||||
@Override
|
||||
protected final void renderMergedOutputModel(
|
||||
Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
|
||||
// Set the content type and get the output stream.
|
||||
response.setContentType(getContentType());
|
||||
OutputStream out = response.getOutputStream();
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractJExcelView extends AbstractView {
|
||||
if (this.url != null) {
|
||||
Workbook template = getTemplateSource(this.url, request);
|
||||
workbook = Workbook.createWorkbook(out, template);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.debug("Creating Excel Workbook from scratch");
|
||||
workbook = Workbook.createWorkbook(out);
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.lowagie.text.PageSize;
|
||||
import com.lowagie.text.pdf.PdfWriter;
|
||||
|
||||
import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract superclass for PDF views, using Bruno Lowagie's
|
||||
* <a href="http://www.lowagie.com/iText">iText</a> package.
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
* {@link org.springframework.web.servlet.ViewResolver} implementation that
|
||||
* resolves instances of {@link AbstractJasperReportsView} by translating
|
||||
* the supplied view name into the URL of the report file.
|
||||
*
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @since 1.2.6
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Provides standard View and ViewResolver implementations,
|
||||
* including abstract base classes for custom implementations.
|
||||
*
|
||||
*
|
||||
* <p>Application developers don't usually need to implement views,
|
||||
* as the framework provides standard views for JSPs, Velocity,
|
||||
* XSLT, etc. However, the ability to implement custom views easily
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -28,7 +28,7 @@ import org.apache.velocity.app.VelocityEngine;
|
||||
* @see VelocityView
|
||||
*/
|
||||
public interface VelocityConfig {
|
||||
|
||||
|
||||
/**
|
||||
* Return the VelocityEngine for the current web application context.
|
||||
* May be unique to one servlet, or shared in the root context.
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.web.util.NestedServletException;
|
||||
|
||||
/**
|
||||
* Convenient superclass for views rendered using an XSLT stylesheet.
|
||||
*
|
||||
*
|
||||
* <p>Subclasses typically must provide the {@link Source} to transform
|
||||
* by overriding {@link #createXsltSource}. Subclasses do not need to
|
||||
* concern themselves with XSLT other than providing a valid stylesheet location.
|
||||
@@ -67,7 +67,7 @@ import org.springframework.web.util.NestedServletException;
|
||||
* the {@link ErrorListener} implementation instance for custom handling of warnings and errors during TransformerFactory operations
|
||||
* <li>{@link #setIndent(boolean) indent} (optional): whether additional whitespace
|
||||
* may be added when outputting the result; defaults to <code>true</code>
|
||||
* <li>{@link #setCache(boolean) cache} (optional): are templates to be cached; debug setting only; defaults to <code>true</code>
|
||||
* <li>{@link #setCache(boolean) cache} (optional): are templates to be cached; debug setting only; defaults to <code>true</code>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note that setting {@link #setCache(boolean) "cache"} to <code>false</code>
|
||||
|
||||
Reference in New Issue
Block a user