I am trying to fix a set of buttons on a JSP page in a Spring MVC framework.
Currently, the link when clicked will cause the URL to look like something akin to
localhost:8080/DADA/servlet/page1?id=92
I need everything after the question mark removed. Can I do this all from the JSP/HTML page, or do I need to go into the controller and change things at that level?
currently it is setup as
<spring: url var = "var1" value="${servletPath}/page1">
<spring: param name="id" value= "${id.id}" />
The answers linked showed a hardcoded variable for the URL that was placed into a JS function. This one is specifically written using spring:url with a separate parameter tag being passed in.
I haven't touched a JSP in years however it sounds like you want something like this:
<spring: url var = "var1" value="${servletPath}/page1/${id.id}">
In which case your controller will need to be updated to accept a path variable.
@RequestMapping("/page1/{id}")
Foo bar(@PathVariable("id") String id) { ... }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.