@@ -198,14 +198,17 @@ public class DispatcherServlet extends FrameworkServlet {
198
198
public static final String PAGE_NOT_FOUND_LOG_CATEGORY = "org.springframework.web.servlet.PageNotFound" ;
199
199
200
200
/**
201
- * Name of the class path resource (relative to the DispatcherServlet class) that defines DispatcherServlet's default
202
- * strategy names.
201
+ * Name of the class path resource (relative to the DispatcherServlet class)
202
+ * that defines DispatcherServlet's default strategy names.
203
203
*/
204
204
private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties" ;
205
205
206
+
206
207
/** Additional logger to use when no mapped handler is found for a request. */
207
208
protected static final Log pageNotFoundLogger = LogFactory .getLog (PAGE_NOT_FOUND_LOG_CATEGORY );
208
209
210
+ private static final UrlPathHelper urlPathHelper = new UrlPathHelper ();
211
+
209
212
private static final Properties defaultStrategies ;
210
213
211
214
static {
@@ -686,7 +689,7 @@ protected Object createDefaultStrategy(ApplicationContext context, Class<?> claz
686
689
@ Override
687
690
protected void doService (HttpServletRequest request , HttpServletResponse response ) throws Exception {
688
691
if (logger .isDebugEnabled ()) {
689
- String requestUri = new UrlPathHelper () .getRequestUri (request );
692
+ String requestUri = urlPathHelper .getRequestUri (request );
690
693
logger .debug ("DispatcherServlet with name '" + getServletName () + "' processing " + request .getMethod () +
691
694
" request for [" + requestUri + "]" );
692
695
}
@@ -838,7 +841,7 @@ protected void doDispatch(HttpServletRequest request, HttpServletResponse respon
838
841
@ Override
839
842
protected long getLastModified (HttpServletRequest request ) {
840
843
if (logger .isDebugEnabled ()) {
841
- String requestUri = new UrlPathHelper () .getRequestUri (request );
844
+ String requestUri = urlPathHelper .getRequestUri (request );
842
845
logger .debug (
843
846
"DispatcherServlet with name '" + getServletName () + "' determining Last-Modified value for [" +
844
847
requestUri + "]" );
@@ -854,7 +857,7 @@ protected long getLastModified(HttpServletRequest request) {
854
857
HandlerAdapter ha = getHandlerAdapter (mappedHandler .getHandler ());
855
858
long lastModified = ha .getLastModified (request , mappedHandler .getHandler ());
856
859
if (logger .isDebugEnabled ()) {
857
- String requestUri = new UrlPathHelper () .getRequestUri (request );
860
+ String requestUri = urlPathHelper .getRequestUri (request );
858
861
logger .debug ("Last-Modified value for [" + requestUri + "] is: " + lastModified );
859
862
}
860
863
return lastModified ;
@@ -958,7 +961,7 @@ protected HandlerExecutionChain getHandler(HttpServletRequest request, boolean c
958
961
*/
959
962
protected void noHandlerFound (HttpServletRequest request , HttpServletResponse response ) throws Exception {
960
963
if (pageNotFoundLogger .isWarnEnabled ()) {
961
- String requestUri = new UrlPathHelper () .getRequestUri (request );
964
+ String requestUri = urlPathHelper .getRequestUri (request );
962
965
pageNotFoundLogger .warn ("No mapping found for HTTP request with URI [" + requestUri +
963
966
"] in DispatcherServlet with name '" + getServletName () + "'" );
964
967
}
0 commit comments