java - 404 error once I click on the submit button in this spring form project -
below pages, please help.
home.jsp
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> <link type="text/css" rel="stylesheet" href="css/homepage.css"> <link type="text/css" rel="stylesheet" href="css/datepickerjqueryui.css"> <script src="js/homepage.js"></script> <script src="js/jquery.js"></script> <script src="js/jquery-1.7.1.min.js"></script> <script src="js/jquery.datepicker.min.js"></script> <script> $(function() { $( "#datepickerdeparture" ).datepicker(); }); $(function() { $( "#datepickerreturn" ).datepicker(); }) </script> </head> <body> <div class="headerbackground"> <!-- headers logo , menu items --> <div class="header"> <div class="logo"><a href="" target="_self"></a></div> <div class="menu"> menu list items </div> </div> </div> <!-- division items between logo header , footer --> <div class="body"> <!-- division search --> <div class="searchbox" > <form action="search" method="get" name="searchbus"> <div class="searchleavingfrom">leaving : <input type="text" name="from" class="txtbox"><h6 id="leavingfrom" class="errormsg"></h6></div> <div class="searchgoingto">going :<input type="text" name="destination" class="txtbox"><h6 id="destination" class="errormsg"></h6></div> <div class="searchdeparton">depart on:<input type = "text" name="departuredate" class="txtbox" id="datepickerdeparture"><h6 id="departure" class="errormsg"></h6></div> <div class="searchreturn">return on:<input type = "text" name="returndate" class="txtbox" id="datepickerreturn"></div> <div><input type="button" name="search" value="search buses" class="searchbtn" onclick="validateform()"></div> </form> </div> </div> <!-- division footer --> <div> </div> </body> </html> web.xml
<web-app id="webapp_id" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>ticketstore</display-name> <welcome-file-list> <welcome-file>home.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>ticketstore</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/ticketstore-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <!--- servlet mapping if put .jsp doesnt run @ mean homepage doesnt display @ all--> </servlet> <servlet-mapping> <servlet-name>ticketstore</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app> ticketstore-servlet.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean class="org.springframework.web.servlet.mvc.support.controllerclassnamehandlermapping" /> <bean name="search" id="search" class="com.ticketgoose.controller.searchdetails"> <property name="formview" value="home" /> <property name="successview" value="searchbuses" /> </bean> <!-- register customer.properties --> <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> </beans> searchdetails.java
package com.ticketgoose.controller; import com.ticketgoose.form.searchform; import org.springframework.stereotype.controller; import org.springframework.validation.bindingresult; import org.springframework.web.bind.annotation.modelattribute; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.sessionattributes; import org.springframework.web.servlet.modelandview; @controller @sessionattributes public class searchdetails { @requestmapping (value = "/search", method = requestmethod.get) public string addcontact(@modelattribute("searchdetails") searchform searchdetails, bindingresult result){ system.out.println("from:" + searchdetails.getfrom() + " to:" + searchdetails.getdestination()); return "redirect:searchbus.html"; } @requestmapping("/searchbus") public modelandview showcontacts() { return new modelandview("searchdetails", "command", new searchform()); } } searchbuses.jsp
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>success page</title> </head> <body> user details <hr> : ${user.name} : ${user.gender} date of jourey: ${user.country} return journey: ${user.aboutyou} </body> </html> this form:
searchform.java
package com.ticketgoose.form; import java.sql.date; public class searchform { string from; string destination; date departuredate; date returndate; //getter setters public string getfrom() { return from; } public void setfrom(string from) { this.from = from; } public string getdestination() { return destination; } public void getdestination(string destination) { this.destination = destination; } public date getdeparturedate() { return departuredate; } public void setdeparturedate(date departuredate) { this.departuredate = departuredate; } public date getreturndate() { return returndate; } public void setreturndate(date returndate) { this.returndate = returndate; }} please me solve this, couldn't figure out problem @ all.
is application running under application context on web server?
try this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <form action="<c:url value="/search" />" method="get" name="searchbus">
Comments
Post a Comment