jodd3.3
来源:互联网 发布:淘宝供货商怎么做 编辑:程序博客网 时间:2024/06/06 03:14
jodd3.3
download url:http://jodd.org/download/index.html
Jodd 3.3发布了,该版本新增了一个Lagarto HTML解析器和Decora页面修饰器以及Jerry和一些小的改进
Jodd是一个普通开源Java包。你可以把Jodd想象成Java的“瑞士军刀”,不仅小,锋利而且包含许多便利的功能。
Jodd提供的功能有:
1. 提供操作Java bean
2. 可以从各种数据源加载Bean
3. 简化JDBC的接连与代码
4. 剖析SQL查询
5. 处理时间与日期
6. 操作与格式化String
7. 搜索本地硬盘上的文件
8. 帮助处理Servlet请求等
除此之外还包含一个很小,但实用的基于JSP的MVC框架。
2.简化JSP页面的 bind, 不需要一个字段一个字段的绑定。
3.对bean没有任何要求,可以使用任意的 bean做为 formBean.
使用方法简介:
1 把jodd.jar放到 web-inf->lib 下,在 web.xml里声名标签:
< taglib-uri>jodd </ taglib-uri >
< taglib-location>/WEB-INF/lib/jodd.jar</taglib-location>
</ taglib>
2 任意的一个javaBean做为FormBean
public classUser {
private String userName;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String pwd) {
this .password = pwd;
}
public String getUserName() {
return userName;
}
public void setUserName(String username) {
this .userName = username;
}
}
3 在JSP页面使用 jodd tag:, 比如对应用户登录页面的
<% @taglib uri = " jodd "prefix= " jodd"%>
<jodd:formbeans="user"scopes ="session">
< form action="my.htm"method="post" >
< table width ="300" border ="0" cellspacing="0"cellpadding="0"
align ="center" class ="white" >
< tr>
< tdheight="32"align ="right" width ="107" >用户名:</ td >
< td height ="32" width ="193" ><inputtype ="text"name ="userName"
class ="input" size ="20" ></td >
</ tr>
< tr>
< tdheight="33"align ="right" width ="107" >密码:</ td >
< tdheight="33"width ="193" >< inputtype="password"name="password"
class ="input" size ="21" ></td>
</ tr>
< tr>
< tdheight="69"align ="center"colspan ="2" >
< inputtype="submit"name ="Submit" value ="登录" >
</ tr>
</ table>
</ form >
</ jodd:form >
4 Dispatch-servelt.xml中对controller 的配置
<bean id="myController" class="caike.MyController">
</bean>
不再需要这种方式:
<!--
<bean id="myController" class="caike.MyFormController">
<property name="commandClass" value="caike" />
<property name="formView" value="userForm" />
</bean>
-->
5 在controller中取出 user
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jodd.bean.BeanUtil;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public classMyControllerimplementsController {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throwsException {
User user = new User();
BeanUtil.load(user, request);
System.out.println( " 用户名: " +user.getUserName()+"密码: " +user.getPassword());
return null ;
}
}
需要注意的地方:
表单中对应的名字 name 和 javaBean 里对应的属性名要相同。
<input type="text"name="userName"
class="input" size="20">
public class User {
private String userName;
.......
- jodd3.3
- jodd3.3
- 3
- 3
- 3
- 3
- 3
- (3)
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- Android异步通信机制(二)
- 由编译错误看-L. -lxxxx的正确位置
- ThinkPHP框架中快捷键M和D的区别
- Beini 的6种攻击模式详解
- C#调用WindowsMediaPlayer控件实现音乐播放(一)
- jodd3.3
- java 编写webservice 接口(xfire) ,调用webservice接口
- 为窗体加上滚动条
- oracle 数据导入不同的表空间-dmp文件
- 硬盘分区表
- 获取字符串的像素长度
- 一个游戏程序员的学习资料
- explicit关键字的使用
- linux c 线程锁