i new spring mvc, maven , tomcat. have written controller have defined bean. when type url in broswer like: localhost:8080/hello.htm controller called , called again when hit url. eg
<bean name="/hello.htm" class="com.paytm.controller.inventorycontroller"> <property name="jdbcproductdao"> <bean class="com.paytm.repository.jdbcproductdao"> <constructor-arg ref="datasource"></constructor-arg> </bean> </property> </bean>
and in controller
public modelandview handlerequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { product product = new product(); product.setprice(23.45); product.setdescription("test product"); this.jdbcproductdao.saveproduct(product); ... }
as result product saved twice in db. query why controller called when type url(and not hit it)?
your browser caches url when sees same url in omnibox every , then. clear cache , fix issue. can check chrome prerenders
typing in chrome browser.
chrome://net-internals/#prerender
for more details can take @ this source
Comments
Post a Comment