I'm working on personal Information.jsp, in which I've to store website in database column. white spaces are stored, if user doesn't give any input. I've used trim()
to avoid that. but It doesn't give proper output.
我正在处理个人Information.jsp,其中我将网站存储在数据库列中。如果用户不提供任何输入,则存储空格。我用trim()来避免这种情况。但它没有给出正确的输出。
Personal Action
String[] splits=webSites.trim().split("//");
String split1=splits[0].trim();
if(split1.equals("http:")|| split1.equals("https:")){
vo.setWebSites(splits[1].trim());
}else{
vo.setWebSites(webSites.trim());
}
PersonalInformation.jsp
<div class="width2 margin-bottom margin-top">
<div class="profile-text">
Website
</div>
<div class="profile-right">
<s:textfield name="webSites" id="webSites" cssClass="profile-input" cssStyle="height:30px;" title="Please enter your website" data-toggle="tooltip" maxlength="50" />
(Example:http://www.loginhire.com)
</div>
</div>
1 个解决方案
#1
0
"white spaces are stored , if user doesn't give any input."
“如果用户不提供任何输入,则存储空格。”
how to avoid storing white spaces?
如何避免存储空白?
validate user input before storing.
存储前验证用户输入。
if(webSites.trim().equals("") || webSites==null)
//prevent from storing to database or alert user
#1
0
"white spaces are stored , if user doesn't give any input."
“如果用户不提供任何输入,则存储空格。”
how to avoid storing white spaces?
如何避免存储空白?
validate user input before storing.
存储前验证用户输入。
if(webSites.trim().equals("") || webSites==null)
//prevent from storing to database or alert user