@@ -78,7 +78,7 @@ public InputStream getResourceStream (String name) throws ResourceNotFoundExcept
7878 throw new ResourceNotFoundException ("WebappResourceLoader: No template name provided" );
7979 }
8080 if (name .startsWith ("/" )){
81- name = name .substring (1 ). trim () ;
81+ name = name .substring (1 );
8282 }
8383 try {
8484 val is = servletContext .getResourceAsStream ('/' + name );// [META-INF/resources] /name
@@ -124,40 +124,44 @@ public boolean isSourceModified (Resource resource) {
124124 rootPath is null if the servlet container cannot translate the virtual path to a real path for any reason
125125 (such as when the content is being made available from a .war archive)
126126
127- @param resource Resource the resource to check
127+ @param templateResource Resource the resource to check
128128 @return long The time when the resource was last modified or 0 if the file can't be read
129129 */
130130 @ Override
131- public long getLastModified (Resource resource ) {
131+ public long getLastModified (Resource templateResource ) {
132+ String name = templateResource .getName ();
133+ if (name .startsWith ("/" )){
134+ name = name .substring (1 );
135+ }
132136 try {
133137 String rootPath = servletContext .getRealPath ("/" );
134- if (rootPath != null ) return new File (rootPath , resource . getName () ).lastModified ();// ? cachedFile.canRead()
138+ if (rootPath != null ) return new File (rootPath , name ).lastModified ();// ? cachedFile.canRead()
135139 } catch (Exception e ){
136- log .warn ("getLastModified: Could not get last modified time for {}" , resource . getName () , e );
140+ log .warn ("getLastModified: Could not get last modified time for {}" , name , e );
137141 }
138142 try {
139- URL url = servletContext .getResource ('/' +resource . getName () );// web /
143+ URL url = servletContext .getResource ('/' +name );// web /
140144 if (url != null ) return url .openConnection ().getLastModified ();
141145 } catch (Exception e ){
142- log .warn ("getLastModified: Could not get last modified time for {}" , resource . getName () , e );
146+ log .warn ("getLastModified: Could not get last modified time for {}" , name , e );
143147 }
144148 try {
145- URL url = ClickUtils .getResource (resource . getName () , getClass ());// /
149+ URL url = ClickUtils .getResource (name , getClass ());// /
146150 if (url != null ) return url .openConnection ().getLastModified ();
147151 } catch (Exception e ){
148- log .warn ("getLastModified: Could not get last modified time for {}" , resource . getName () , e );
152+ log .warn ("getLastModified: Could not get last modified time for {}" , name , e );
149153 }
150154 try {
151- URL url = ClickUtils .getResource ("templates/" +resource . getName () , getClass ());
155+ URL url = ClickUtils .getResource ("templates/" +name , getClass ());
152156 if (url != null ) return url .openConnection ().getLastModified ();
153157 } catch (Exception e ){
154- log .warn ("getLastModified: Could not get last modified time for {}" , resource . getName () , e );
158+ log .warn ("getLastModified: Could not get last modified time for {}" , name , e );
155159 }
156160 try {
157- URL url = ClickUtils .getResource ("static/" + resource . getName () , getClass ());
161+ URL url = ClickUtils .getResource ("static/" + name , getClass ());
158162 if (url != null ) return url .openConnection ().getLastModified ();
159163 } catch (Exception e ){
160- log .warn ("getLastModified: Could not get last modified time for {}" , resource . getName () , e );
164+ log .warn ("getLastModified: Could not get last modified time for {}" , name , e );
161165 }
162166 return 0 ;
163167 }
0 commit comments