0

Spring MVC "duplicates" parts of the URL I looked at the previous link but the answers did not work and did not seem relevant (unless I'm doing something wrong).

My jboss-web.xml root is "/portal"

I have an jsp doc (with only html in it) that posts to a java controller that authenticates a username and password. The formaction is "portal/index".

<input type="submit" name="submit" value="Submit" onclick="return validation()" formaction="portal/index"/>

The controller's class level path annotation is "portal". The method that I want it to post to has a path annotation "/index".

@Controller
@Path("portal")
public class TheController
{....}

@POST
@Path("/index")
public Response login()
{....}

If the password and username are correct, then the method will forward to home.jsp. Otherwise, it will go back to index.jsp. For some reason, when I submit the form with the incorrect username and password the 1st time, it will go back to "portal/portal/index" (the form will show up) and if I submit it incorrectly a 2nd time, it will go to "portal/portal/portal/index" and the security filter it goes through will return a 404 not found. What is wrong with my set up that is leading to the duplicating URL?

Community
  • 1
  • 1
  • if your application root is portal, why you using @path("portal") on controller ? – coder Jul 30 '14 at 14:23
  • I've tried it without the @path("portal") and the problem persists. Originally, I thought you needed the path annotations to match the formaction. – user3688447 Jul 30 '14 at 14:33

1 Answers1

0

Try using /index in form action, you are using relative path, I think that is causing the issue. Also remove @path("portal") from your controller.

Update: Try this in formaction "${pageContext.request.contextPath}/index"

coder
  • 4,458
  • 2
  • 17
  • 23