struts2页面上double类型的数据转换成整数

来源:互联网 发布:汤姆索亚历险记 知乎 编辑:程序博客网 时间:2024/05/01 10:31

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ taglib prefix="s" uri="/struts-tags"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'userLst.jsp' starting page</title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
<script type="text/javascript">
function formate(){
return 34;

}

</script>
  </head>
  <body style="background-image: url('../imgs/1.jpg');" background="../imgs/1.jpg">
   <s:form action="" theme="simple">
    <table border="1" width="50%">
     <tr>
      <td colspan="4" align="center">基础信息</td>
     </tr>
     <s:iterator value="userList" id="u">
      <tr>
       <td><s:property value="#u.merName"/></td>
       <td><s:property value="#u.merPay"/></td>
       <td><s:property value="formate2Num(#u.merPay)"/></td>
      </tr>
     </s:iterator>
    </table>
   </s:form>
  </body>
</html>

formate2Num是java中定义的一个方法

public int formate2Num(double obj){
  return (int)obj;
 }

在java中把double类型的数据转换成int类型的,然后在jsp页面输出

 

原创粉丝点击