skip to Main Content

I’ve got the templates folder, in which there is current page. From it I’m trying to get access to .svg files, which are located inside templates/icons folder. My goal is to customize the checkboxes so that they change their apperance from one svg file to the other depending on their state. Whatever I do, I’m getting the internal server error.
How do I do that?

Here is what i got:

<style>
                input[type="checkbox"] {
                display: none;
                border: none !important;
                box-shadow: none !important;
                }

                input[type="checkbox"] + label span {
                background-image: url('/icons/grey_arrow.svg');
                width: 24px;
                height: 24px;
                display: inline-block;
                vertical-align: middle;
                background-size: 100%;
                }

                input[type="checkbox"]:checked + label span {
                background-image: url('/icons/white_arrow.svg');
                width: 24px;
                height: 24px;
                vertical-align: middle;
                background-size: 100%;
                }
</style>
<body>
        <form th:action="@{/products/{productId}/features/{featureId}/votes(productId=${feature.product.id},featureId=${feature.id})}" method="post" th:id="voting">
            <div class="form-check">                                        
                <input class="form-check-input" type="checkbox" id="vote" th:name="upvote" th:checked="${upvote}" onclick="updateCheckboxes(this, document.getElementById('downvote'))">
                <label class="form-check-label" for="vote">
                    <span class="checkbox-icon-wrapper">
                        <span>
                        <!-- i was trying to just make it appear-->
                            <img src = "./icons/white_arrow.svg"/>
                        </span>
                    </span>
                    upvote
                </label>
            </div>
            <div class="form-check">
                <input class="form-check-input" type="checkbox" id="downvote" th:name ="upvote" th:checked="${upvote} == false" th:value="${upvote} == false" onclick="updateCheckboxes(this, document.getElementById('vote'))">
                <label class="form-check-label" for="downvote">
                    <span class="checkbox-icon-wrapper">
                        <span class="checkbox-icon glyphicon glyphicon-ok"></span>
                    </span>
                    downvote
                </label>
            </div>
        </form>
</body>

Security config:

@Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception
    {
        return
                http.headers(headers -> headers.disable())
                        .authorizeHttpRequests(requests -> requests
                                .requestMatchers("/").permitAll()
                                .requestMatchers("/register").permitAll()
                                .requestMatchers("/icons/**").permitAll()
                                .anyRequest().hasRole("USER"))
                        .formLogin(login -> login
                                .loginPage("/login")
                                .defaultSuccessUrl("/dashboard")
                                .permitAll())
                        .logout(logout -> logout
                                .logoutUrl("/logout").permitAll()).build();
    }

StackTrace

2024-02-09T15:46:12.441+01:00 DEBUG 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Securing GET /icons/white_arrow.svg
2024-02-09T15:46:12.507+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Trying to match request against DefaultSecurityFilterChain [RequestMatcher=any request, Filters=[org.springframework.security.web.session.DisableEncodeUrlFilter@6612f94, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2f75cd15, org.springframework.security.web.context.SecurityContextHolderFilter@77dc0a74, org.springframework.web.filter.CorsFilter@4d23f6d0, org.springframework.security.web.csrf.CsrfFilter@91633e0, org.springframework.security.web.authentication.logout.LogoutFilter@11138745, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@6305199f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@41abbd8e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@799a1f68, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6a1c70a, org.springframework.security.web.access.ExceptionTranslationFilter@73f21b63, org.springframework.security.web.access.intercept.AuthorizationFilter@6ea182a1]] (1/1)
2024-02-09T15:46:12.510+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking DisableEncodeUrlFilter (1/12)
2024-02-09T15:46:12.510+01:00 DEBUG 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Securing GET /icons/grey_arrow.svg
2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking WebAsyncManagerIntegrationFilter (2/12)
2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking DisableEncodeUrlFilter (1/12)
2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking SecurityContextHolderFilter (3/12)2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking WebAsyncManagerIntegrationFilter (2/12)
2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking CorsFilter (4/12)
2024-02-09T15:46:12.511+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking SecurityContextHolderFilter (3/12)
2024-02-09T15:46:12.577+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking CsrfFilter (5/12)
2024-02-09T15:46:12.579+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking CorsFilter (4/12)
2024-02-09T15:46:12.580+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.csrf.CsrfFilter         : Did not protect against CSRF since request did not match CsrfNotRequired [TRACE, HEAD, GET, OPTIONS]
2024-02-09T15:46:12.580+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking CsrfFilter (5/12)
2024-02-09T15:46:12.580+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking LogoutFilter (6/12)
2024-02-09T15:46:12.580+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.csrf.CsrfFilter         : Did not protect against CSRF since request did not match CsrfNotRequired [TRACE, HEAD, GET, OPTIONS]
2024-02-09T15:46:12.581+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.s.w.a.logout.LogoutFilter            : Did not match request to Ant [pattern='/logout', POST]
2024-02-09T15:46:12.581+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking UsernamePasswordAuthenticationFilter (7/12)
2024-02-09T15:46:12.581+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking LogoutFilter (6/12)
2024-02-09T15:46:12.583+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.s.w.a.logout.LogoutFilter            : Did not match request to Ant [pattern='/logout', POST]
2024-02-09T15:46:12.583+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking UsernamePasswordAuthenticationFilter (7/12)
2024-02-09T15:46:12.582+01:00 TRACE 16768 --- [nio-8080-exec-8] w.a.UsernamePasswordAuthenticationFilter : Did not match request to Ant [pattern='/login', POST]
2024-02-09T15:46:12.583+01:00 TRACE 16768 --- [nio-8080-exec-1] w.a.UsernamePasswordAuthenticationFilter : Did not match request to Ant [pattern='/login', POST]
2024-02-09T15:46:12.584+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking RequestCacheAwareFilter (8/12)
2024-02-09T15:46:12.584+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking RequestCacheAwareFilter (8/12)
2024-02-09T15:46:12.584+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.s.w.s.HttpSessionRequestCache        : matchingRequestParameterName is required for getMatchingRequest to lookup a value, but not provided
2024-02-09T15:46:12.585+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.s.w.s.HttpSessionRequestCache        : matchingRequestParameterName is required for getMatchingRequest to lookup a value, but not provided
2024-02-09T15:46:12.585+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking SecurityContextHolderAwareRequestFilter (9/12)
2024-02-09T15:46:12.585+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking SecurityContextHolderAwareRequestFilter (9/12)
2024-02-09T15:46:12.586+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking AnonymousAuthenticationFilter (10/12)2024-02-09T15:46:12.586+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking AnonymousAuthenticationFilter (10/12)2024-02-09T15:46:12.586+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking ExceptionTranslationFilter (11/12)
2024-02-09T15:46:12.586+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking ExceptionTranslationFilter (11/12)
2024-02-09T15:46:12.587+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Invoking AuthorizationFilter (12/12)
2024-02-09T15:46:12.587+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Invoking AuthorizationFilter (12/12)
2024-02-09T15:46:12.587+01:00 TRACE 16768 --- [nio-8080-exec-8] estMatcherDelegatingAuthorizationManager : Authorizing SecurityContextHolderAwareRequestWrapper[ FirewalledRequest[ org.springframework.security.web.debug.DebugFilter$DebugRequestWrapper@e83f53e]]
2024-02-09T15:46:12.588+01:00 TRACE 16768 --- [nio-8080-exec-1] estMatcherDelegatingAuthorizationManager : Authorizing SecurityContextHolderAwareRequestWrapper[ FirewalledRequest[ org.springframework.security.web.debug.DebugFilter$DebugRequestWrapper@ea2169f]]
2024-02-09T15:46:12.588+01:00 TRACE 16768 --- [nio-8080-exec-8] estMatcherDelegatingAuthorizationManager : Checking authorization on SecurityContextHolderAwareRequestWrapper[ FirewalledRequest[ org.springframework.security.web.debug.DebugFilter$DebugRequestWrapper@e83f53e]] using org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer$$Lambda/0x0000021d019dec70@7442f0e3
2024-02-09T15:46:12.588+01:00 TRACE 16768 --- [nio-8080-exec-1] estMatcherDelegatingAuthorizationManager : Checking authorization on SecurityContextHolderAwareRequestWrapper[ FirewalledRequest[ org.springframework.security.web.debug.DebugFilter$DebugRequestWrapper@ea2169f]] using org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer$$Lambda/0x0000021d019dec70@7442f0e3
2024-02-09T15:46:12.589+01:00 DEBUG 16768 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Secured GET /icons/grey_arrow.svg
2024-02-09T15:46:12.589+01:00 DEBUG 16768 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy        : Secured GET /icons/white_arrow.svg
2024-02-09T15:46:12.591+01:00  WARN 16768 --- [nio-8080-exec-8] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.servlet.resource.NoResourceFoundException: No static resource icons/white_arrow.svg.]
2024-02-09T15:46:12.593+01:00 TRACE 16768 --- [nio-8080-exec-8] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal={ id='1', username='[email protected]', password='$2a$10$xFBv/wuBWS9ScUD4zSDXKefnnok39VwurbmXK3HH6reKArKKaYgpm', name='Shekel', authorities='[com.freshvotes.security.Authority@2231856c]'}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=3CFF340DF9E91216EFD1908962A6CB64], Granted Authorities=[com.freshvotes.security.Authority@2231856c]]] from SPRING_SECURITY_CONTEXT
2024-02-09T15:46:12.591+01:00  WARN 16768 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.servlet.resource.NoResourceFoundException: No static resource icons/grey_arrow.svg.]
2024-02-09T15:46:12.594+01:00 TRACE 16768 --- [nio-8080-exec-1] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal={ id='1', username='[email protected]', password='$2a$10$xFBv/wuBWS9ScUD4zSDXKefnnok39VwurbmXK3HH6reKArKKaYgpm', name='Shekel', authorities='[com.freshvotes.security.Authority@2231856c]'}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=3CFF340DF9E91216EFD1908962A6CB64], Granted Authorities=[com.freshvotes.security.Authority@2231856c]]] from SPRING_SECURITY_CONTEXT
2024-02-09T15:46:12.595+01:00 TRACE 16768 --- [nio-8080-exec-1] o.s.s.w.a.AnonymousAuthenticationFilter  : Did not set SecurityContextHolder since already authenticated UsernamePasswordAuthenticationToken [Principal={ id='1', username='[email protected]', password='$2a$10$xFBv/wuBWS9ScUD4zSDXKefnnok39VwurbmXK3HH6reKArKKaYgpm', name='Shekel', authorities='[com.freshvotes.security.Authority@2231856c]'}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=3CFF340DF9E91216EFD1908962A6CB64], Granted Authorities=[com.freshvotes.security.Authority@2231856c]]
2024-02-09T15:46:12.593+01:00 TRACE 16768 --- [nio-8080-exec-8] o.s.s.w.a.AnonymousAuthenticationFilter  : Did not set SecurityContextHolder since already authenticated UsernamePasswordAuthenticationToken [Principal={ id='1', username='[email protected]', password='$2a$10$xFBv/wuBWS9ScUD4zSDXKefnnok39VwurbmXK3HH6reKArKKaYgpm', name='Shekel', authorities='[com.freshvotes.security.Authority@2231856c]'}, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=3CFF340DF9E91216EFD1908962A6CB64], Granted Authorities=[com.freshvotes.security.Authority@2231856c]]
2024-02-09T15:46:12.605+01:00  INFO 16768 --- [nio-8080-exec-3] Spring Security Debugger

2

Answers


  1. Chosen as BEST ANSWER

    Okay, I figured it out. I had to move the icons folder outside of the templates folder. It was before resources->templates->icons and now it is resources->static->icons.

    I suppose it has to do with the security configuration or the spring-boot specifics but I'm not really sure.


  2. might you should add xmlns="http://www.w3.org/2000/svg" in your svg file

    like

    <svg width="34" height="34" viewBox="0 0 24 24" fill="none" 
    

    // below attribute add your svg file

    xmlns="http://www.w3.org/2000/svg"&gt;

        <svg width="34" height="34" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M4 4.5L20 4.5" stroke="#141B34" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    <path d="M4 14.5L20 14.5" stroke="#141B34" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    <path d="M4 9.5L20 9.5" stroke="#141B34" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    <path d="M4 19.5L20 19.5" stroke="#141B34" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    </svg>
    

    then your svg image is appeared in page

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search