网站快照
星 途 星 途 S t a r l i n k ( C o d r e a m s H o m e p a g e ) 首 页 关 于 标 签 4 分 类 2 0 R S S 搜 索 文 章 目 录 站 点 概 览 C o d r e a m B l o g 2 0 日 志 2 0 分 类 4 标 签 G i t H u b E M a i l 链 接 W e b s i t e G i t e e T h y m e l e a f p a g i n a t i o n 发 表 于 2 0 2 4 0 1 1 2 更 新 于 2 0 2 4 0 1 1 4 分 类 于 S o f t w a r e , J a v a , S p r i n g b o o t T h y m e l e a f 分 页 模 板 L i v e 发 表 于 2 0 2 4 0 1 1 1 更 新 于 2 0 2 4 0 1 1 4 分 类 于 L i v e W e l c o m e t o H e x o ! T h i s i s y o u r v e r y f i r s t p o s t . C h e c k d o c u m e n t a t i o n f o r m o r e i n f o . I f y o u g e t a n y p r o b l e m s w h e n u s i n g H e x o , y o u c a n f i n d t h e a n s w e r i n t r o u b l e s h o o t i n g o r y o u c a n a s k m e o n G i t H u b . Q u i c k S t a r t C r e a t e a n e w p o s t 1 $ h e x o n e w M y N e w P o s t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t M o r e i n f o : W r i t i n g R u n s e r v e r 1 $ h e x o s e r v e r M o r e i n f o : S e r v e r G e n e r a t e s t a t i c f i l e s 1 $ h e x o g e n e r a t e M o r e i n f o : G e n e r a t i n g D e p l o y t o r e m o t e s i t e s 1 $ h e x o d e p l o y M o r e i n f o : D e p l o y m e n t C r e t u r n m o d e l A n d V i e w ; } 注 意 返 回 码 : 3 0 1 , 返 回 2 0 0 就 空 白 S p r i n g b o o t s t a t i c 静 态 文 件 不 能 访 问 发 表 于 2 0 2 4 0 1 1 1 更 新 于 2 0 2 4 0 1 1 4 分 类 于 S o f t w a r e , J a v a , S p r i n g b o o t s t a t i c 静 态 文 件 不 能 访 问 S p r i n g b o o t s t a t i c 静 态 文 件 不 能 访 问 原 因 记 录 1 、 S p r i n g b o o t 2 . 7 + 配 置 文 件 继 承 e x t e n d s W e b M v c C o n f i g u r a t i o n S u p p o r t 后 不 能 访 问 W h e n d e v e l o p i n g a S p r i n g B o o t a p p l i c a t i o n , i t ’ s i m p o r t a n t t o b e a b l e t o s e r v e s t a t i c c o n t e n t s u c h a s i m a g e s , H T M L , C S S , a n d J a v a S c r i p t f i l e s . H o w e v e r , s o m e t i m e s t h e s e s t a t i c f i l e s m a y n o t b e a c c e s s i b l e e v e n i f t h e y a r e p l a c e d i n t h e c o r r e c t d i r e c t o r y . O n e c o m m o n r e a s o n f o r t h i s i s s u e i s t h a t S p r i n g B o o t s e r v e s s t a t i c c o n t e n t f r o m t h e / s t a t i c o r / p u b l i c d i r e c t o r y b y d e f a u l t . I f t h e s t a t i c f i l e s a r e l o c a t e d i n a d i f f e r e n t d i r e c t o r y , t h e y m a y n o t b e a c c e s s i b l e . T o s o l v e t h i s i s s u e , y o u c a n c o n f i g u r e t h e l o c a t i o n o f t h e s t a t i c f i l e s b y a d d i n g t h e f o l l o w i n g c o d e t o y o u r a p p l i c a t i o n . p r o p e r t i e s f i l e : 1 2 3 4 5 6 7 s p r i n g : m v c : s t a t i c p a t h p a t t e r n : / s t a t i c / * * w e b : r e s o u r c e s : s t a t i c l o c a t i o n s : c l a s s p a t h : / s t a t i c / , c l a s s p a t h : / p u b l i c / , f i l e : / h o m e / s t a t i c / T h i s c o d e t e l l s S p r i n g B o o t t o l o o k f o r s t a t i c f i l e s i n t h e / s t a t i c d i r e c t o r y w i t h i n t h e c l a s s p a t h . A n o t h e r r e a s o n w h y s t a t i c f i l e s m a y n o t b e a c c e s s i b l e i s i f t h e y a r e n o t i n c l u d e d i n t h e b u i l d p r o c e s s . M a k e s u r e t h a t t h e s t a t i c f i l e s a r e i n c l u d e d i n t h e s r c / m a i n / r e s o u r c e s / s t a t i c d i r e c t o r y a n d t h a t t h e y a r e a d d e d t o t h e b u i l d p r o c e s s . I n c o n c l u s i o n , i f y o u ’ r e h a v i n g t r o u b l e a c c e s s i n g s t a t i c f i l e s i n y o u r S p r i n g B o o t a p p l i c a t i o n , m a k e s u r e t h a t t h e y a r e l o c a t e d i n t h e c o r r e c t d i r e c t o r y a n d t h a t t h e y a r e i n c l u d e d i n t h e b u i l d p r o c e s s . A d d i t i o n a l l y , y o u c a n c o n f i g u r e t h e l o c a t i o n o f t h e s t a t i c f i l e s i n t h e a p p l i c a t i o n . p r o p e r t i e s f i l e t o e n s u r e t h a t t h e y a r e a c c e s s i b l e . 在 S p r i n g c l o u d 环 境 下 要 访 问 单 个 服 务 的 静 态 资 源 需 要 在 静 态 资 源 路 径 加 路 径 标 识 如 : r e s o u r c e s / s t a t i c / c m s / a s s e t s / * * * G a m e 发 表 于 2 0 2 4 0 1 1 1 更 新 于 2 0 2 4 0 1 1 4 分 类 于 G a m e T e t r i s T h e h i s t o r y o f T e t r i s r a n d o m i z e r s S i m o n L a r o c h e D e v e l o p e r s i m o n l c / t e t r . j s 1 2 粤 I C P 备 2 0 2 5 4 3 6 1 1 6 号 粤 公 网 安 备 4 4 0 3 0 0 0 2 0 0 2 0 8 2 号 © 2 0 2 5 C O D R E A M 0 % T h e m e N e x T w o r k s b e s t w i t h J a v a S c r i p t e n a b l e d