Hello there,
I am created an online form using SpringMVC tag library (as a JSP file) and also a Controller (think Model View Controller pattern) as a RESTful Web Service.
When I deploy and invoke the web service by doing this in the browser:
http://localhost:8080/myapp/applications/new
Am able to view the SpringMVC based form (in Firefox) but when I enter in information and click on Submit, it displays the following:
The RESTful Web Service (Controller):Code:HTTP Status 404 - /application/new type Status report message /application/new description The requested resource (/application/new) is not available.
applications_new.jsp (Here's the view (which does launch when I invoke it)):Code:@Controller @Path(ApplicationResource.APPLICATION_URL) public class ApplicationResource { private final Logger log = LoggerFactory.getLogger(ApplicationResource.class); public static final String APPLICATION_URL = "/applications"; @Autowired private ApplicationManager applicationManager; @POST @Path("create") @Produces(MediaType.TEXT_HTML) public ModelAndView getNewApplication(@Context HttpServletRequest request) { log.debug("Inside getNewApplication() method."); ModelAndView modelAndView = new ModelAndView("/applications/applications_new"); String message = ""; try { if ("POST".equalsIgnoreCase(request.getMethod())) { String name = request.getParameter("name"); String description = request.getParameter("description"); String imgUrl = request.getParameter("imgUrl"); Application app = new Application(); if (app != null) { app.setName(name); app.setDescription(description); app.setImgUrl(imgUrl); applicationManager.save(app); message = "Added application: " + app.getName(); } else { message = "Invalid"; } modelAndView.addObject("message", message); } } catch(Exception e) { log.info("Exception: ", e); throw new WebApplicationException(Response.status(RestError.SERVER_ERROR_HTTP_RESP) .type("application/json;charset=utf-8").entity(new ErrorOutput(RestError.SERVER_ERROR_CODE,RestError.SERVER_ERROR_MSG,e.toString())).build()); } return modelAndView; } @GET @Path("new") @Produces({ MediaType.TEXT_HTML}) public ModelAndView getNewApplicationForm() { ModelAndView mv = new ModelAndView("/applications/applications_new"); mv.addObject("application", new Application()); log.debug("Inside getNewApplicationForm"); return mv; } }
What could I be possibly be doing wrong?Code:<%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <html> <body> <form:form commandName="application" method="POST" action="/application/new"> <table> <tr> <td>Name:</td> <td><form:input path="name"/></td> </tr> <tr> <td>Description:</td> <td><form:input path="description" /></td> </tr> <tr> <td>Image URL:</td> <td><form:input path="imgUrl" /></td> </tr> </table> <input type="submit" value="submit" /> </form:form> </body> </html>
Thank you for taking the time to read this...


Reply With Quote
