Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to connect css and javascript in a .jsp file

$
0
0

I am having trouble connecting an external css and javascript file to its jsp.

I tried doing the WebConfig as I read on google but I realised that my jsp files' path are done via application.properties so when it ran it override the application.properties and the .jsp could not be found. I deleted the WebConfig and stuck with the application.properties and tried to add a filepath for css

spring.mvc.view.prefix=/WEB-INF/views/ spring.mvc.view.suffix=.jsp  spring.web.resources.statstaticic-locations=classpath:/static/,classpath:/public/,classpath:/resources/,classpath:/META-INF/resources/ 

These made the JSP run but it could not read the css.

File Path for JSP:src-> main -> webapp-> home.jsp home.jsp:

<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="c:url value='/css/home.css' />">     <title>Project One</title> </head> <body>

File Path for CSS:src-> main-> resources-> static-> css-> home.css

I am not sure if this matters but these are the dependencies I am using (gradle):

dependencies {   implementation 'org.springframework.boot:spring-boot-starter-web'   developmentOnly 'org.springframework.boot:spring-boot-devtools'   testImplementation 'org.springframework.boot:spring-boot-starter-test'  implementation 'org.springframework.boot:spring-boot-starter-data-jpa'  runtimeOnly 'com.mysql:mysql-connector-j'   runtimeOnly 'org.apache.tomcat.embed:tomcat-embed-jasper:10.1.9' //jsp   runtimeOnly 'org.glassfish.web:jakarta.servlet.jsp.jstl:3.0.0'  //helpful jsp tags

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>