I am trying to get to the following URL in thyemleaf. This is basically a button that when clicked supposed to increment a value in the backend and turn a boolean value to true. Each of these path variables comes from a different entity which in my case I refer to them uip and pid. I tried to run the debugger in eclipse but did not even reach/hit my endpoint in my controller. Also, I am not getting a stack trace of any error other than console output with no error.
part of the HTML
<table id="multi-color-bg" class="table table-bordered table-striped" >
<thead>
<tr>
<th>Party Symbols</th>
<th>Party Name</th>
<th th:if="${#request.userPrincipal.principal.isVoted == false}">Vote Here</th>
<th id="action" th:if="!user.isVoted" >Action</th>
</tr>
</thead>
<tbody>
<tr th:each=" party : ${parties}">
<td th:text="${party.id}">Party ID</td>
<td th:text="${party.name}">Party Name</td>
<td th:if="${#request.userPrincipal.principal.isVoted == false}">
<form th:action="@{/vote/{uid}(uid=${#request.userPrincipal.principal.id}/{pid}(pid=${party.id})}" method="post">
<button id="voted" > Vote Here</button>
</form>
</td>
<td class="actionButtons">
Controller
@PostMapping("/vote/{uid}/{pid}")
public String vote(@PathVariable Long uid, @PathVariable Long pid) {
Optional<User> user = userService.findById(uid);
if(user.isPresent()) {
User foundUser = user.get();
foundUser.setIsVoted(true);
userService.update(foundUser);
}
Party party = partyService.findPartyById(pid);
if(party.getId() != null) {
partyService.vote(pid);
}
return "redirect:/";
}
when I click on the button I get Whitelabel error page 404 with the following URL:
http://localhost:8080/vote/%7Buid%7D(uid=$%7B?pid=1#request.userPrincipal.principal.id}/{pid}
Here is the console output as you can see no error is there
Hibernate: select user0_.id as id1_3_, user0_.created_date as created_2_3_, user0_.email as email3_3_, user0_.first_name as first_na4_3_, user0_.voted as voted5_3_, user0_.last_name as last_nam6_3_, user0_.password as password7_3_, user0_.username as username8_3_ from users user0_ where user0_.username=?
Hibernate: select roles0_.user_id as user_id1_2_0_, roles0_.role_id as role_id2_2_0_, role1_.id as id1_1_1_, role1_.role_name as role_nam2_1_1_ from user_roles roles0_ inner join roles role1_ on roles0_.role_id=role1_.id where roles0_.user_id=?
2022-06-13 02:50:58.062 DEBUG 509262 --- [nio-8080-exec-5] o.s.s.a.dao.DaoAuthenticationProvider : Authenticated user
2022-06-13 02:50:58.062 DEBUG 509262 --- [nio-8080-exec-5] .s.ChangeSessionIdAuthenticationStrategy : Changed session id from 7D7E807F5E7CD7CF9BF2E7C59C1E3C97
2022-06-13 02:50:58.062 DEBUG 509262 --- [nio-8080-exec-5] w.a.UsernamePasswordAuthenticationFilter : Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]
2022-06-13 02:50:58.063 DEBUG 509262 --- [nio-8080-exec-5] o.s.s.web.DefaultRedirectStrategy : Redirecting to http://localhost:8080/?
2022-06-13 02:50:58.063 DEBUG 509262 --- [nio-8080-exec-5] w.c.HttpSessionSecurityContextRepository : Stored SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]] to HttpSession [org.apache.catalina.session.StandardSessionFacade@60edf337]
2022-06-13 02:50:58.063 DEBUG 509262 --- [nio-8080-exec-5] w.c.HttpSessionSecurityContextRepository : Stored SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]] to HttpSession [org.apache.catalina.session.StandardSessionFacade@60edf337]
2022-06-13 02:50:58.063 DEBUG 509262 --- [nio-8080-exec-5] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:50:58.065 DEBUG 509262 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy : Securing GET /?
2022-06-13 02:50:58.066 DEBUG 509262 --- [nio-8080-exec-6] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.066 DEBUG 509262 --- [nio-8080-exec-6] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.066 DEBUG 509262 --- [nio-8080-exec-6] o.s.s.w.s.HttpSessionRequestCache : Loaded matching saved request http://localhost:8080/?
2022-06-13 02:50:58.067 DEBUG 509262 --- [nio-8080-exec-6] o.s.s.w.a.i.FilterSecurityInterceptor : Authorized filter invocation [GET /?] with attributes [authenticated]
2022-06-13 02:50:58.067 DEBUG 509262 --- [nio-8080-exec-6] o.s.security.web.FilterChainProxy : Secured GET /?
Hibernate: select party0_.id as id1_0_, party0_.party_name as party_na2_0_, party0_.vote_count as vote_cou3_0_ from parties party0_
2022-06-13 02:50:58.107 DEBUG 509262 --- [nio-8080-exec-6] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:50:58.124 DEBUG 509262 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : Securing GET /css/partiesview.css
2022-06-13 02:50:58.125 DEBUG 509262 --- [nio-8080-exec-7] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.125 DEBUG 509262 --- [nio-8080-exec-7] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.125 DEBUG 509262 --- [nio-8080-exec-7] o.s.s.w.a.i.FilterSecurityInterceptor : Authorized filter invocation [GET /css/partiesview.css] with attributes [permitAll]
2022-06-13 02:50:58.125 DEBUG 509262 --- [nio-8080-exec-7] o.s.security.web.FilterChainProxy : Secured GET /css/partiesview.css
2022-06-13 02:50:58.128 DEBUG 509262 --- [nio-8080-exec-7] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:50:58.128 DEBUG 509262 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy : Securing GET /partiesview.js
2022-06-13 02:50:58.128 DEBUG 509262 --- [nio-8080-exec-8] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.128 DEBUG 509262 --- [nio-8080-exec-8] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.129 DEBUG 509262 --- [nio-8080-exec-8] o.s.s.w.a.i.FilterSecurityInterceptor : Authorized filter invocation [GET /partiesview.js] with attributes [authenticated]
2022-06-13 02:50:58.129 DEBUG 509262 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy : Secured GET /partiesview.js
2022-06-13 02:50:58.130 DEBUG 509262 --- [nio-8080-exec-8] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:50:58.132 DEBUG 509262 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy : Securing GET /error
2022-06-13 02:50:58.132 DEBUG 509262 --- [nio-8080-exec-8] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.132 DEBUG 509262 --- [nio-8080-exec-8] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:50:58.133 DEBUG 509262 --- [nio-8080-exec-8] o.s.security.web.FilterChainProxy : Secured GET /error
2022-06-13 02:50:58.176 DEBUG 509262 --- [nio-8080-exec-8] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:51:01.482 DEBUG 509262 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy : Securing POST /vote/{uid}(uid=${?pid=1
2022-06-13 02:51:01.483 DEBUG 509262 --- [nio-8080-exec-9] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:51:01.483 DEBUG 509262 --- [nio-8080-exec-9] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:51:01.484 DEBUG 509262 --- [nio-8080-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor : Authorized filter invocation [POST /vote/{uid}(uid=${?pid=1] with attributes [permitAll]
2022-06-13 02:51:01.484 DEBUG 509262 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy : Secured POST /vote/{uid}(uid=${?pid=1
2022-06-13 02:51:01.494 DEBUG 509262 --- [nio-8080-exec-9] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2022-06-13 02:51:01.494 DEBUG 509262 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy : Securing POST /error?pid=1
2022-06-13 02:51:01.495 DEBUG 509262 --- [nio-8080-exec-9] w.c.HttpSessionSecurityContextRepository : Retrieved SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:51:01.495 DEBUG 509262 --- [nio-8080-exec-9] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=com.voiceit.security.MyUserDetail@2fb87471, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=7D7E807F5E7CD7CF9BF2E7C59C1E3C97], Granted Authorities=[user]]]
2022-06-13 02:51:01.495 DEBUG 509262 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy : Secured POST /error?pid=1
2022-06-13 02:51:01.502 DEBUG 509262 --- [nio-8080-exec-9] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
@{/vote/{uid}/{pid}(uid=${#request.userPrincipal.principal.id}, pid=${party.id})}in your example the pid part is withing the()which is used for assigning variables/vote/{uid}(uid=${?pid=1should not be possible. For thymeleaf path variables see baeldung.com/spring-thymeleaf-path-variables