java - The requested resource is not available on my bookstore application -
i keep getting error dont know how figure out. complete web.xml file believe solely web.xml issue. or there other file causing requested resource problem...
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- processes application requests --> <servlet> <servlet-name>dispatcherservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring/dispatcherservlet/servlet-context.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
this bookcontroller code
@controller @requestmapping("/book") public class bookcontroller { @autowired private bookservice bookservice; @requestmapping(value = { "/", "/listbooks" }) public string listbooks(map<string, object> map) { map.put("book", new book()); map.put("booklist", bookservice.listbooks()); return "/book/listbooks"; } @requestmapping("/get/{bookid}") public string getbook(@pathvariable long bookid, map<string, object> map) { book book = bookservice.getbook(bookid); map.put("book", book); return "/book/bookform"; } @requestmapping(value = "/save", method = requestmethod.post) public string savebook(@modelattribute("book") book book, bindingresult result) { bookservice.savebook(book); /* * note there no slash "/" right after "redirect:" so, * redirects path relative current path */ return "redirect:listbooks"; } @requestmapping("/delete/{bookid}") public string deletebook(@pathvariable("bookid") long id) { bookservice.deletebook(id); /* * redirects path relative current path */ // return "redirect:../listbooks"; /* * note there slash "/" right after "redirect:" so, * redirects path relative project root path */ return "redirect:/book/listbooks"; }
this root-context.xml code
<context:component-scan base-package="np.com.mshrestha.bookstore" /> <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <!-- <property name="ignoreunresolvableplaceholders" value="true" /> --> <property name="locations"> <list> <value>classpath:database.properties</value> </list> </property> </bean> <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close" p:driverclassname="${jdbc.driverclassname}" p:url="${jdbc.url}" p:username="${jdbc.username}" /> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="packagestoscan"> <list> <value>np.com.mshrestha.bookstore.model</value> </list> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">false</prop> </props> </property> </bean> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <tx:annotation-driven transaction-manager="transactionmanager" /> </beans>
i can see warning on console
warning: no mapping found http request uri [/bookstore/] in dispatcherservlet name 'dispatcherservlet'
please how can resolve error once , in application. many thanks
Comments
Post a Comment