1.问题描述
使用kendo ui的textarea,前台输入的空格多于一个的时候存入后台后空格的个数不对,有的变成了问号?
2.问题分析
debug前端js和java后台发现分明都是正常的空格显示,但是输出到日志和存入数据库的都不对,有问号。看来是编码的问题,查资料发现:
http://blog.csdn.net/wuhongyao3/article/details/5834921,看来确实是编码问题,而且非常隐蔽。debug前端js,把textarea的值拷贝到ue里以2进制查看,确实是出现了0x3f.
3.解决
上面引用的url的解决办法是c#版的,java后台可以:
byte[] space = new byte[]{(byte)0xc2,(byte)0xa0};
String UTFSpace = null;
try
{
UTFSpace = new String(space,"utf-8");
}
catch (Exception e)
{
log.error("", e);
}
// 这里的smsContent就是前端传过来的包含乱码的值。
smsContent = smsContent.replace(UTFSpace," ");
分享到:
相关推荐
<transmission><forwardGears/></transmission> <speed>1234</speed> <heading>456</heading> <accelSet> <long>12</long> <lat>34</lat> <vert>56</vert> <yaw>78</yaw> </accelSet> <brakes> </brakes>...
<strong>Title</strong>:<%=Html.Encode(book.Title) %></br> <strong>Author</strong>:<%=Html.Encode(book.Author) %></br> <strong>PubDate</strong>:<%=Html.Encode(book.PubDate.ToShortDateString()) %>...
</script>`匹配所有包含`<script>`开头并以`</script>`结尾的内容,其中`[^>]*?`表示任意数量的非`>`字符,`.*?`则表示匹配任意内容直到找到`</script>`为止。`RegexOptions.IgnoreCase`使得匹配不区分大小写。 2. ...
input control flag=<int put=0 encode&decode out_name?> <int put=1 encode out_name?> <int put=2 decode out_name?> <1> 1 回车 <2> control_flag=1 <3> input in_name? <4> FR_in.INP 回车 <5> input out_name...
<employee><serial_no>100002</serial_no><name>Elaine</name><age>24</age><birthday>1982-01-01</birthday><salary>6000.00</salary><bonus>2000.00</bonus> </employee></employees> </depart> <depart><name...
<artifactId>core</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.4.1</version> </dependency> ``` ...
htmlencode=replace(replace(str,chr(13),"<br>"),"'","''") end function dim rs,sql set rs=server.createobject("adodb.recordset") if request.querystring="add" then if request("title")="" then ...
<br><br>public class CreatePic<br>{<br> public static void gg()<br> {<br> try {<br> BufferedImage bufImg = new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);<br> Graphics2D g2d = (Graphics2D)...
bftools encode braincopter <file | -> --original <original image> [--output <output image>] Decoding bftools decode brainloller <image | -> [--output <output image>] bftools decode braincopter <image...
3. **处理换行**:将`<br>`和`</p><p>`标签转换回换行符`\n`,以还原原文档中的换行格式。 #### 四、UrlEncode与UrlDecode的作用 除了HtmlEncode与HtmlDecode外,文中还提到了`UrlEncode`和`UrlDecode`的概念。这...
/// <summary> /// 簡體轉繁體 /// </summary> /// <param name="str"></param> /// <returns></returns> public static string Simplified2Traditional(string str) { EncodeMy.EncodeRobert eer = new ...
String xml = "<person><name>张三</name><age>30</age><city>北京</city></person>"; JsonNode jsonNode = xmlMapper.readTree(xml); ObjectMapper jsonMapper = new ObjectMapper(); String jsonString = json...
request取参数时转化编码<br>##<br>param = no<br>param.from=ISO-8859-1<br>param.to=GB2312<br><br># 写入数据到数据库转化编码<br>encode = no<br>encode.from=ISO-8859-1<br>encode.to=GB2312<br><br># 从数据库...
在Java后台开发中,生成二维码是一项常见的需求,例如用于生成下载链接、电子票务或支付码等。本篇文章将深入探讨如何使用Java实现二维码生成工具类,并提供一个实用的示例。 首先,我们需要理解二维码的基本原理。...
Map<String, Object> map = new HashMap<>(); map.put("trackingNumber", orderPerson.getTrackingNumber()); map.put("senderCompany", orderPerson.getSenderCompany()); map.put("senderName", orderPerson....
filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); Files.copy(file.toPath(), response.getOutputStream()); } else { throw new FileNotFoundException("文件不存在!"); } } } ``` 在这个...
Map<EncodeHintType, ErrorCorrectionLevel> hints = new HashMap<>(); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); try { BitMatrix bitMatrix = new QRCodeWriter().encode(content...
If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) End If ' boolean to abort record edit Dim MM_abortEdit MM_abortEdit = false %> <% ' ...
<artifactId>javacv-platform</artifactId> <version>1.5.4</version> </dependency> <dependency> <groupId>com.github.sergio-martinez-r</groupId> <artifactId>javacv</artifactId> <version>1.5.4</...