我是 Spring 新手,我正在开发一个虚拟银行交易项目。到目前为止,我已经创建了一个欢迎页面,将我链接到可以执行存款或取款交易的页面。数据库和一切工作正常。而且,我有一个表格,显示具有 4 个属性(id、name、acctNo、balance)的客户列表。该 ID 链接到下一页,我只想显示有关此客户的信息。我怎样才能做到这一点。
Dispatcher-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"
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>
<!-- I tried adding this bean but noe luck, not sure where to use this id to map this 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>
bean=showindividualcustomer 的控制器是:
public class showCustomerController extends SimpleFormController{
protected ModelAndView onSubmit(Object obj) throws ServletException{
return new ModelAndView("ViewCustomer");//name of the jsp page inside WEB-INF/jsp
}
}
谢谢!!!