如<td class="list_right" align="left" title=<bean:write name="logs" property="remark"/>> <bean:write name="logs" property="remark"/> </td>
如果remak的值为1234567890asdfg 就显示为1234.... 如果remark值为123 就显示123
给出代码好吗
12 个解决方案
#1
那你就修改对应的remark的getter方法啦,
getRemark(){
if(remark!=null){
return remark>x?remark.substring(0,x):remark;
}
}
getRemark(){
if(remark!=null){
return remark>x?remark.substring(0,x):remark;
}
}
#2
getRemark(){
if(remark!=null){
return remark.length()>=4?remark.substring(0,4)+".......":remark;
}
return "";
}
修改了一下
if(remark!=null){
return remark.length()>=4?remark.substring(0,4)+".......":remark;
}
return "";
}
修改了一下
#3
我写了个util:
public final static String getCutString(String input, int start, int len,
String tail) {
String str = cutString(input, start, len);
if (str.length() > 0 && str.length() < input.length()) {
return str + tail;
}
return str;
}
jsp:
<%=com.common.util.Util.getCutString(productintroduce,0,70,"...")%>
//4个参数分别是要截取的字符,开始地方,截取个数,替代被截取内容的符号
public final static String getCutString(String input, int start, int len,
String tail) {
String str = cutString(input, start, len);
if (str.length() > 0 && str.length() < input.length()) {
return str + tail;
}
return str;
}
jsp:
<%=com.common.util.Util.getCutString(productintroduce,0,70,"...")%>
//4个参数分别是要截取的字符,开始地方,截取个数,替代被截取内容的符号
#4
你是<bean:write>的
那要先定义下:
<bean:define id="productintroduce" name="product" property="productintroduce" type="java.lang.String"></bean:define>
<%=org.caexpo.common.util.Util.getCutString(productintroduce,0,70,"...")%>
那要先定义下:
<bean:define id="productintroduce" name="product" property="productintroduce" type="java.lang.String"></bean:define>
<%=org.caexpo.common.util.Util.getCutString(productintroduce,0,70,"...")%>
#5
bean属性如我上面写的<td>中的bean属性remark可以作为参数传递吗?
#6
楼上的虽然比较灵活些,不过在jsp页面上写起来就麻烦一点点。各有所长!
#7
整个应用代码
<logic:iterate scope="request" name="report_data" property="datas" id="logs" indexId="id">
<tr <%=id.intValue() %2 == 0 ? "" : "class=\"list1\""%>>
<td class="list_border" align="center" height="20"><bean:write name="logs" property="id" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileName" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileType" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="dealTime" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="savedNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="errorRecordrNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="totalRecorderNum" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="errorType" /> </td>
<td class="list_right" align="left" title=<bean:write name="logs" property="remark"/>> <bean:write name="logs" property="remark"/> </td>
</tr>
</logic:iterate>
<logic:iterate scope="request" name="report_data" property="datas" id="logs" indexId="id">
<tr <%=id.intValue() %2 == 0 ? "" : "class=\"list1\""%>>
<td class="list_border" align="center" height="20"><bean:write name="logs" property="id" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileName" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileType" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="dealTime" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="savedNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="errorRecordrNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="totalRecorderNum" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="errorType" /> </td>
<td class="list_right" align="left" title=<bean:write name="logs" property="remark"/>> <bean:write name="logs" property="remark"/> </td>
</tr>
</logic:iterate>
#8
我想知道在jsp如何处理,不希望改变后台java类
#9
写成歌util是因为多个jsp要截,这样方便。
如果只用一次,那么就把代码截出来,放到jsp的<%%>中
如果只用一次,那么就把代码截出来,放到jsp的<%%>中
#10
我想知道在jsp如何处理,不希望改变后台java类
----------------------------------------------------------------
定义一个变量
<bean:define id="logmark" name="logs" property="remark" type="java.lang.String"/>
<%=(logremark.length()>=4?logremark.substring(0,4)+"...":logremark)%>
----------------------------------------------------------------
定义一个变量
<bean:define id="logmark" name="logs" property="remark" type="java.lang.String"/>
<%=(logremark.length()>=4?logremark.substring(0,4)+"...":logremark)%>
#11
这东西你也问
#12
利用substring()方法就可以了 首先判断字符串的长度,如果超过某一长度就用substring方法截取,后跟“......”,反之则不用substring方法
#1
那你就修改对应的remark的getter方法啦,
getRemark(){
if(remark!=null){
return remark>x?remark.substring(0,x):remark;
}
}
getRemark(){
if(remark!=null){
return remark>x?remark.substring(0,x):remark;
}
}
#2
getRemark(){
if(remark!=null){
return remark.length()>=4?remark.substring(0,4)+".......":remark;
}
return "";
}
修改了一下
if(remark!=null){
return remark.length()>=4?remark.substring(0,4)+".......":remark;
}
return "";
}
修改了一下
#3
我写了个util:
public final static String getCutString(String input, int start, int len,
String tail) {
String str = cutString(input, start, len);
if (str.length() > 0 && str.length() < input.length()) {
return str + tail;
}
return str;
}
jsp:
<%=com.common.util.Util.getCutString(productintroduce,0,70,"...")%>
//4个参数分别是要截取的字符,开始地方,截取个数,替代被截取内容的符号
public final static String getCutString(String input, int start, int len,
String tail) {
String str = cutString(input, start, len);
if (str.length() > 0 && str.length() < input.length()) {
return str + tail;
}
return str;
}
jsp:
<%=com.common.util.Util.getCutString(productintroduce,0,70,"...")%>
//4个参数分别是要截取的字符,开始地方,截取个数,替代被截取内容的符号
#4
你是<bean:write>的
那要先定义下:
<bean:define id="productintroduce" name="product" property="productintroduce" type="java.lang.String"></bean:define>
<%=org.caexpo.common.util.Util.getCutString(productintroduce,0,70,"...")%>
那要先定义下:
<bean:define id="productintroduce" name="product" property="productintroduce" type="java.lang.String"></bean:define>
<%=org.caexpo.common.util.Util.getCutString(productintroduce,0,70,"...")%>
#5
bean属性如我上面写的<td>中的bean属性remark可以作为参数传递吗?
#6
楼上的虽然比较灵活些,不过在jsp页面上写起来就麻烦一点点。各有所长!
#7
整个应用代码
<logic:iterate scope="request" name="report_data" property="datas" id="logs" indexId="id">
<tr <%=id.intValue() %2 == 0 ? "" : "class=\"list1\""%>>
<td class="list_border" align="center" height="20"><bean:write name="logs" property="id" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileName" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileType" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="dealTime" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="savedNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="errorRecordrNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="totalRecorderNum" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="errorType" /> </td>
<td class="list_right" align="left" title=<bean:write name="logs" property="remark"/>> <bean:write name="logs" property="remark"/> </td>
</tr>
</logic:iterate>
<logic:iterate scope="request" name="report_data" property="datas" id="logs" indexId="id">
<tr <%=id.intValue() %2 == 0 ? "" : "class=\"list1\""%>>
<td class="list_border" align="center" height="20"><bean:write name="logs" property="id" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileName" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="fileType" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="dealTime" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="savedNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="errorRecordrNum" /> </td>
<td class="list_right" align="right"><bean:write name="logs" property="totalRecorderNum" /> </td>
<td class="list_right" align="left"> <bean:write name="logs" property="errorType" /> </td>
<td class="list_right" align="left" title=<bean:write name="logs" property="remark"/>> <bean:write name="logs" property="remark"/> </td>
</tr>
</logic:iterate>
#8
我想知道在jsp如何处理,不希望改变后台java类
#9
写成歌util是因为多个jsp要截,这样方便。
如果只用一次,那么就把代码截出来,放到jsp的<%%>中
如果只用一次,那么就把代码截出来,放到jsp的<%%>中
#10
我想知道在jsp如何处理,不希望改变后台java类
----------------------------------------------------------------
定义一个变量
<bean:define id="logmark" name="logs" property="remark" type="java.lang.String"/>
<%=(logremark.length()>=4?logremark.substring(0,4)+"...":logremark)%>
----------------------------------------------------------------
定义一个变量
<bean:define id="logmark" name="logs" property="remark" type="java.lang.String"/>
<%=(logremark.length()>=4?logremark.substring(0,4)+"...":logremark)%>
#11
这东西你也问
#12
利用substring()方法就可以了 首先判断字符串的长度,如果超过某一长度就用substring方法截取,后跟“......”,反之则不用substring方法