java - <c:url> tag and contextPath doesn't display properly path -
i want redirect client following paths when particural text clicked, <a href="${userurl}"> query </a>and <a href="${removeuserurl}"> remove </a> works properly. contextpath "basics" , jsp displayed path "http://localhost:8080/basics/". when click on update or add user, redirects me "http://localhost:8080/basics/basics/users" (the jsp file users.jsp) should redirects respectively "http://localhost:8080/basics/user/update/${customer.id}" , "http://localhost:8080/basics/user/add" what's wrong code?
users.jsp:
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>users</title> //...style </head> <body> <c:set value="${pagecontext.request.contextpath}" var="contexturl" /> <c:set value="${contexturl}/user/add" var="adduserurl" /> <table style="width: 100%"> <tr> <th>#id</th> <th>name</th> <th>age</th> <th>country</th> <td colspan="3" style="background-color: #0cf323; text-align: center; border-top-color: #0cf323; border-right-color: #0cf323"> <a href="<c:url value='/user/add' />"> add user </a> </td> </tr> <c:foreach var="customer" items="${customers}"> <c:set value="${contexturl}/user/update/${customer.id}" var="updateuserurl" /> <c:set value="${contexturl}/user/remove/${customer.id}" var="removeuserurl" /> <c:set value="${contexturl}/user/${customer.id}" var="userurl" /> <tr> <td><c:out value="${customer.id }" /></td> <td><c:out value="${customer.name }" /></td> <td><c:out value="${customer.age }" /></td> <td><c:out value="${customer.country.country }" /></td> <td style="background-color: #17d0f5"><a href="${userurl}"> query </a></td> <td style="background-color: #ff8000"><a href="${updateuserurl}"> update </a></td> <td style="background-color: #ec2727"><a href="${removeuserurl}"> remove </a></td> </tr> </c:foreach> </table> </body> </html>
try replace this:
<a href="<c:url value='/user/add' />"> add user </a> with using double quote "" , adding var="uservar":
<a href="<c:url value="/user/add" var="uservar" />">add user</a> and use ${uservar} want.
Comments
Post a Comment