Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid url path in spring mvc.

 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I am new to spring mvc.doing a sample project using spring mvc.
In the project,I have a href.I mentioned the correct URL path
in that h ref.but due to append of duplicate URL path,Jsp page
which I am trying to hit is not triggered.

I googled,but not find a suggestion.

For that reason I have mentioned the below story.



In inventory.jsp,this code will invoke "priceincrease.jsp" through FormController's initForm(mentioned below)
<c:url value="price/increase" var="theAction" />
<a href="<c:url value="${theAction}"/>">Increase Prices</a>





In priceincrease.jsp,I am submitting the form,and "inventory.jsp" is called now.
"price" is getting appended with "submitter" because priceincrease.jsp is called
by the above code("/price/increase")
<c:url value="submitter" var="theAction" />
<form:form method="post" commandName="priceIncrease" action="${theAction}">
<input type="submit" align="center" value="Execute">



inventory.jsp is called now.
So far so good.

The issue arise here.
In inventory.jsp,I have a href,
<c:url value="price/increase" var="theAction" />
<a href="<c:url value="${theAction}"/>">Increase Prices</a>

the url found here is "price/price/increase" which is wrong.
"price" is getting appended with the "price/increase".

So when I click the href,page is not displayed due to the wrong path.("price/price/increase")
"price" from @RequestMapping("/price") PriceIncreaseFormController,is getting appended with
"price/increase" of inventory.jsp.

How to handle this?.
"price" of @RequestMapping("/price") PriceIncreaseFormController is appended
to any url(price/increase) that we are calling.and this makes the invalid path("price/price/increase").

Please help me in this issue.

Regards,
Anand
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic