当前位置:编程学习 > JAVA >>

时期在文本框中的显示

String hufId=request.getParameter("hufId");
HumanFile humanFile=(HumanFile)humanFileBiz.getObject(HumanFile.class, Short.parseShort(hufId));
request.setAttribute("humanFile", humanFile);

这样的代码HumanFile对象包含时期,怎么将这个时期舍去时分秒并且显示在文本框<html:text property="birthday" value=""></text>中 --------------------编程问答-------------------- 你HumanFile里面怎么获取到日期,是java.util.Date还是什么类型? --------------------编程问答-------------------- 就是在页面可以用el表达式点出来。。。。${humanFile.birthday },就是那个值不知道怎么转换。。。 --------------------编程问答-------------------- 你想要将birthday传出去什么类型的,我这里将birthday以字符串传出去,你也没说清楚怎么个类型,

问题都表达不清楚 ……

<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%--
  Created by IntelliJ IDEA.
  User: gaoyong
  Date: 2011-10-10
  Time: 22:44:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Date birthday=new Date(); //birthday表示你获得的日期
    String birStr=new SimpleDateFormat("yyyyMMdd").format(birthday);
    request.setAttribute("birthday",birStr);
    System.out.println(birStr);
%>
<html>
  <head><title>Simple jsp page</title></head>
  <body>Place your content here
  <html:text property="birthday" value="${birStr}">
  </html:text>
  </body>
</html>



引用 2 楼 yxt19891210 的回复:
就是在页面可以用el表达式点出来。。。。${humanFile.birthday },就是那个值不知道怎么转换。。。
--------------------编程问答-------------------- 这是Action中的方法:       
//复核
public ActionForward check(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String hufId=request.getParameter("hufId");
HumanFile humanFile=(HumanFile)humanFileBiz.getObject(HumanFile.class, Short.parseShort(hufId));
request.setAttribute("humanFile", humanFile);
return mapping.findForward("human_check");
}



在页面接受
<td width="13%" class="TD_STYLE2">
<html:text property="humanBirthday" value="<fmt:formatDate value='${humanFile.humanBirthday }' pattern='yyyy-MM-dd'></fmt:formatDate>" styleClass="INPUT_STYLE2" ></html:text></td>
这样转不了。。。。
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,