在Java中修剪字符串,删除空格 [英] trim string in java, remove white space

查看:74
本文介绍了在Java中修剪字符串,删除空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%=CMSStringUtility.toTitleCase(attrValues.getDisplayLabel())%>

这将返回一个带有前导空格字符的字符串,我需要将其删除.我相信这是jsp文件中的JAVA.我尝试了以下方法:

this returns a string with a leading white space character that I need to remove. I believe this is JAVA in a jsp file. I tried the following:

<%=CMSStringUtility.toTitleCase(attrValues.getDisplayLabel()).trim()%>

<%=CMSStringUtility.toTitleCase(attrValues.getDisplayLabel().trim())%>

我是JSP新手,有什么想法吗?

I am a JSP newbie, any ideas?

推荐答案

如果trim()没有删除空格,则表示它不在预定义的空格列表中.这通常是一个不间断的空间(代码160).尝试迭代toCharArray()并查看空格的ascii代码.

If trim() does not remove a whitespace, it means it is not in the predefined list of whitespaces. This is usually a non-breaking space (code 160). Try to iterate the toCharArray() and see the ascii code of the space.

这篇关于在Java中修剪字符串,删除空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆