javascript - Spring Boot Web Static resources -


डॉक्स के अनुसार स्प्रिंग बूट रजिस्टरों src / main / resources / static , src स्थैतिक संसाधन स्थानों के लिए / मुख्य / संसाधन / सार्वजनिक , src / main / resources / संसाधनों आदि।

मुझे मिला

  src / main / resources -static -js -stomp.js   

और html (में रखा गया टेम्पलेट फ़ोल्डर):

  & lt; script type = "text / javascript" th: src = "@ {/ js / stomp.js}" & gt; & lt; / स्क्रिप्ट & gt;   

लेकिन मुझे स्क्रिप्ट के लिए 404 मिली ( GET http: // localhost: 8080 / js / stomp.js 404 (नहीं मिला) )। मैं क्या कर रहा हूं?

मैंने भी

  & lt; script type = "text / javascript" src = "../static / js / stomp.js" & gt; ; & lt; / लिपि & gt;   

और

  & lt; script type = "text / javascript" src = "/ js / stomp.js" & gt; & lt; / स्क्रिप्ट & gt;    = {"नियंत्रक"}) @ कॉन्फिगरेशन लोक वर्ग WebMvcConfig WebMvcConfigurerAdapter {@Override सार्वजनिक शून्य addViewControllers (ViewControllerRegistry रजिस्ट्री) विस्तारित करता है {registry.addViewController ("/ sock")। setViewName ("/ index"); }}   

और मुझे मिल गया

  & lt; निर्भरता & gt; & LT; ग्रुप & gt; org.springframework.boot & lt; / ग्रुप & gt; & LT; artifactId & gt; वसंत-बूट स्टार्टर-वेब & lt; / artifactId & gt; & Lt; / निर्भरता & gt; पीओएम में   

स्पष्ट घोषणा @EnableWebMvc वेब एमवीसी के लिए स्प्रिंग बूट की स्वतः कॉन्फ़िगरेशन अक्षम करता है

या तो अपने WebMvcConfig से इसे हटाएं, स्वतः कॉन्फ़िगरेशन को सक्षम करने के लिए, या addResourceHandlers () में मैन्युअल रूप से स्थिर सामग्री के लिए संसाधन हैंडलर्स जोड़ें यदि आप नहीं चाहते हैं स्वतः कॉन्फ़िगरेशन सक्षम करें।

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

Installing croogo for cakephp -

c# - Use custom conventions when persisting Rebus sagas in MongoDb -