jsp - Spring MVC- how to resolve views? -
i new spring , developing dummy bank transaction project. upto have created welcome page links me page can perform deposit or withdraw transaction. database , works fine. and, have table shows list of customers having 4 attributes(id, name, acctno, balance). id linked next page want show info customer. how can accomplish this.
the dispatcher-servlet.xml is:
<?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" xmlns:p="http://www.springframework.org/schema/p"> <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/jsp/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <bean id="urlmapping" class="org.springframework.web.servlet.handler.simpleurlhandlermapping"> <property name="interceptors"> <list> <ref local="localechangeinterceptor"/> </list> </property> <property name="urlmap"> <map> <entry key="/login.html"> <ref bean="userlogincontroller"/> </entry> </map> </property> </bean> <!-- tried adding bean noe luck, not sure utilize id map bean --> <bean id="showindividualcustomer" class="com.showcustomercontroller">s <property name="successview"> <value>viewcustomer</value></property> </bean> <bean id="userlogincontroller" class="com.userloginformcontroller"> <property name="sessionform"><value>false</value></property> <property name="commandname"><value>userlogin</value></property> <property name="commandclass"><value>com.userlogin</value></property> <property name="formview"><value>userlogin</value></property> <property name="successview"><value>showcustomer</value></property> </bean> <bean id="localechangeinterceptor" class="org.springframework.web.servlet.i18n.localechangeinterceptor"> <property name="paramname" value="hl"/> </bean> <bean id="localeresolver" class="org.springframework.web.servlet.i18n.sessionlocaleresolver"/> </beans>
and controller bean=showindividualcustomer is:
public class showcustomercontroller extends simpleformcontroller{ protected modelandview onsubmit(object obj) throws servletexception{ homecoming new modelandview("viewcustomer");//name of jsp page within web-inf/jsp } }
thank you!!!
i recommend taking total advantage of spring 3, looking @ code assume you're looking @ spring 2 tutorial.
using spring 2.5.6 or spring 3.* do:
@requestmapping(value="/customer/{id}") public string showcustomerinformation(@pathvariable string id, httpservletrequest request){ //your logic client info , pass on homecoming "customerinformation"; }
some references: http://tech-read.com/2011/10/31/spring-3-mvc-annotations/ http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-requestparam
edit: alter method signature to:
onsubmit(httpservletrequest request, object command) throws servletexception
and use:
request.getparameter("id")
jsp spring-mvc
No comments:
Post a Comment