Building dynamic URL using 'a href'

Viewed 52486

I am using spring-3.2 version.

@RequestMapping("/company={companyId}/branch={branchId}/employee={employeeId}/info")

The requestmapping is used to map a URL, so in this case when ever a URL is called using

<a href="company=1/branch=1/employee=1/info" > employee info </a>

the method is called in the controller with the exact @RequestMapping annotation, now I want to create the "a href" tag dynamically and want to create companyId,branchId,or employeeId dynamically.

3 Answers

We can use following example:

<a id="addBtn" href="#" onclick="get_dynamic_url();">Google</a></p>

<script>
function get_dynamic_url() {
    url = "Your dynamic url value";
    $("#addBtn").attr("href", url);
    return true;
}
</script>
Related