Announcement Announcement Module
Collapse
No announcement yet.
Subfolder in form action Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Subfolder in form action

    I have problem, how to create uri in action attribute. I have to use subfolders as "user", "admin" because I use Spring Security.

    Code:
    @RequestMapping(value = "reservationTour.html", method = RequestMethod.POST)
    	public String reservationTour(@ModelAttribute(value = "bookTourForm") BookTourForm bookTourForm, ModelMap model) {
    //code
    		return "user/reservationTourComplete";
    	}
    I tried to use:
    Code:
    <form:form action="/user/reservationTour.html" method="post" commandName="bookTourForm">
    Result, no project name http://localhost:8080/user/reservationTour.html

    Code:
    <form:form action="user/reservationTour.html" method="post" commandName="bookTourForm">
    Result, 2x user in link http://localhost:8080/ProjectContext...ationTour.html

    Code:
    <form:form action="<c:url value="/user/reservationTour.html" />" method="post" commandName="bookTourForm">
    Result, exception
    Code:
    org.apache.jasper.JasperException: /jsp/user/reservationTourPage.jsp(7,33) Unterminated &lt;form:form tag
    This works fine, but for sure is not good solution

    Code:
    <form:form action="/ProjectContextName/user/reservationTour.html" method="post" commandName="bookTourForm">
    I tried to use relative URL
    Code:
    <form:form action="reservationTour.html" method="post" commandName="bookTourForm">
    but I think that it is not correct in this case.
    Suppose that I have method:

    Code:
    @RequestMapping(value = "reservationTour.html", method = RequestMethod.GET)
    public String testReservationTour(ModelMap model) {
    		return "user/reservationTourComplete";
    	}
    Using URL
    http://localhost:8080/TourWebSpring/...ationTour.html
    user can access page in `user` folder without loging.
    Apart from security problem, I don't know why, this last solution slimly does not work.
    Last edited by LancerX; Feb 18th, 2012, 02:44 PM.

  • #2
    For others with simmilar problem in future.
    Relative URL is OK
    Code:
    <form:form action="reservationTour.html" method="post" commandName="bookTourForm">
    But value in request mapping was wrong. It shoud be:
    Code:
    @RequestMapping(value = "user/reservationTour.html", method = RequestMethod.POST)

    Comment

    Working...
    X