<%@ taglib prefix="jodd" uri="http://www.springside.org.cn/jodd_form"%>
任意的一个javaBean做为FormBean
package joddform;
public class User {
private String userName;
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
在JSP页面使用jodd tag:,比如对应用户登录页面的
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<html>
<head>
<title>jodd from测试</title>
</head>
<body>
<jodd:form bean="user" scope="session">
<form action="joddform.do" method="post">
<table width="300" align="center">
<tr>
<td>
用户名:
</td>
<td>
<input type="text" name="userName">
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="登录">
</td>
</tr>
</table>
</form>
</jodd:form>
</body>
</html>
Dispatch-servelt.xml中对controller的配置
<bean id="joddformController" class="joddform.JoddformController">
</bean>
不再需要这种方式:
<bean id="joddformhandlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>joddform.do=joddformController</value>
</property>
</bean>
<bean id="joddformController" class="joddform.JoddformController">
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>