06-将整型值转换为字符串(字符串处理)
来源:互联网 发布:2016大学生网购数据 编辑:程序博客网 时间:2024/05/22 12:40
StringUtil.java
package com.lh.bean;public class StringUtil {// 转换前的int值private int intValue = 0;// 转换后的字符串1值private String strValue1;// 转换后的字符串2值private String strValue2;// 转换后的字符串3值private String strValue3;// 默认构造方法public StringUtil() {}public String getStrValue1() {// 使用String类的valueOf方法转换return String.valueOf(intValue);}public String getStrValue2() {// 使用Integer类的toString方法转换return Integer.toString(intValue);}public String getStrValue3() {// 使用Integer.valueOf().toString方法return Integer.valueOf(intValue).toString();}public int getIntValue() {return intValue;}public void setIntValue(int intValue) {this.intValue = intValue;}public void setStrValue1(String strValue1) {this.strValue1 = strValue1;}public void setStrValue2(String strValue2) {this.strValue2 = strValue2;}public void setStrValue3(String strValue3) {this.strValue3 = strValue3;}}
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><html><head><title>My JSP 'index.jsp' starting page</title></head><body><%int userAge = 35;%><!-- 使用useBean动作导入StringUtil类 --><jsp:useBean id="strBean" class="com.lh.bean.StringUtil"></jsp:useBean><!-- 对StringUtil类对象中的IntValue属性赋值 --><jsp:setProperty property="intValue" name="strBean"value="<%=userAge %>" /><table><tr bgcolor="skyblue"><td align="center">使用String.valueOf()方法转换int值:</td></tr><tr><td align="center"><!-- 获得StringUtil类对象中的strValue1属性值 --> 年龄1:<jsp:getPropertyproperty="strValue1" name="strBean" />岁</td></tr><tr bgcolor="skyblue"><td align="center">使用Integer.toString()方法转换int值:</td></tr><tr><td align="center"><!-- 获得StringUtil类对象中的strValue2属性值 --> 年龄2:<jsp:getPropertyproperty="strValue2" name="strBean" />岁</td></tr><tr bgcolor="skyBlue"><td align="center">使用Integer.valueOf().toString()方法转换int值:</td></tr><tr><td align="center"><!-- 获得StringUtil类对象中的strValue3属性值 --> 年龄3:<jsp:getPropertyproperty="strValue3" name="strBean" />岁</td></tr></table></body></html>
- 06-将整型值转换为字符串(字符串处理)
- javascript 将字符串类型转换为整型
- 将字符串转换为整型的函数
- c#将字符串转换为整型
- 将一个整型变量转换为字符串
- mfc如何将整型转换为字符串
- 将一个整型变量转换为字符串
- 将数字字符串转换为整型
- C++中怎样将整型值转换为字符串
- 整型转换为字符串
- 字符串转换为整型
- 字符串转换为整型
- 字符串转换为整型
- 字符串转换为整型
- 字符串转换为整型
- 07-String类型转换为整型(字符串处理)
- 怎样将一个整型值转换为一个字符串?(C++方法)
- 18-将字符串转换为Calendar对象(字符串处理)
- CCNA学习笔记1-OSI参考模型
- CCNA学习笔记2-TCP/IP协议栈
- 蚁群算法
- CCNA学习笔记3-IP地址+子网划分
- CCNA学习笔记4-安装Cisco设备
- 06-将整型值转换为字符串(字符串处理)
- 利用curses库编程开始
- Class对象
- 一个计算机专业学生几年的Java编程经验汇总
- Android中的Intent详细讲解
- 教你恢复硬盘格式化的数据
- 个人小项目——飞聊通讯录V1.0小结
- 事务
- poj 2778 DNA Sequence