在url参数中发送十六进制字符串并尝试将其转换为服务器端的字符串.使用以下javascript编码代码转换用户输入字符串
function encode(string) {
var number = "";
var length = string.trim().length;
string = string.trim();
for (var i = 0; i < length; i++){
number += string.charCodeAt(i).toString(16);
}
return number;
}
Run Code Online (Sandbox Code Playgroud)
现在我试图在java代码中解析419俄语字符的十六进制字符串,?如下所示
byte[] bytes = "".getBytes();
try {
bytes = Hex.decodeHex(hex.toCharArray());
sb.append(new String(bytes,"UTF-8"));
} catch (DecoderException e) {
e.printStackTrace(); // Here it gives error 'Odd number of characters'
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但它给出了以下错误
"org.apache.commons.codec.DecoderException: Odd number of characters."
Run Code Online (Sandbox Code Playgroud)
如何解决.由于有许多俄罗斯字符有十六进制代码3位数,因此它无法将其转换为.toCharArray()
我从servlet获取数据和我从servlet发送的json对象的sysout是 {"jsonArray":[{"bugzilla":20,"redmind":14}]}
现在我的java脚本是
<script type="text/javascript">
var chart;
$(document).ready(
function() {
chart = new Highcharts.Chart({
chart : {
renderTo : 'container',
},
title : {
text : 'Bug chart'
},
tooltip : {
formatter : function() {
var s;
if (this.point.name) { // the pie chart
s = '' + this.point.name + ': ' + this.y
+ ' Bugs';
} else {
s = '' + this.x + ': ' + this.y;
}
return s;
}
},
labels : {
items …Run Code Online (Sandbox Code Playgroud) 我有一个文本框,可以从用户那里获得多个电子邮件ID.并在工具提示中显示它,但我需要在新行显示每封电子邮件(以逗号分隔).
为此,需要检测逗号并为其添加新行字符.
HTML是
<input type="text" id="email"> <div id="ttip"></div>
Run Code Online (Sandbox Code Playgroud)
jquery for tooltip
$("#email").keyup(showTooltip);
var showTooltip = function(e) {
var tooltip = $(this).val();
if (tooltip == '') {
hideTooltip();
} else if (e.which == 188) {
tooltip += "<br>";
$("#ttip").fadeIn().html(tooltip);
} else {
$("#ttip").fadeIn().html(tooltip);
}
}?
Run Code Online (Sandbox Code Playgroud)
因此,当我的工具提示在div中显示时,它没有检测到<br>并且它显示在同一行上.
我该如何解决?
我试图从控制器获取jsp中的表单对象.JSP :: updateuser.jsp
<form name="user" action="updateuser" method="post">
<ul>
<li>
<label>User Name</label> <input type="text" name="userName" />
</li>
<li>
<label>Password</label> <input type="password" name="password" />
</li>
<li>
<label>FirstName</label> <input type="text" name="firstName" />
</li>
<li>
<label>LastName</label> <input type="text" name="lastName" />
</li>
</ul>
<button type="submit">Update</button>
</form>
Run Code Online (Sandbox Code Playgroud)
Controller :: UpdateUserController.java
@RequestMapping("/updateuser")
public class UpdateUserController {
@RequestMapping(method = RequestMethod.POST)
public ModelAndView update(@ModelAttribute("user") User user,
ModelMap model,HttpServletRequest request) {
return new ModelAndView("updateuser","user",model);
}
}
Run Code Online (Sandbox Code Playgroud)
在任何字段中添加值并单击更新按钮后.表单被提交并在映射的POJO中我获得了价值.现在我想在字段中显示这些值,而不是model.addAttribute("userName", user.getUserName()逐个添加到模型对象(即)所有字段中).另外,我不想使用Spring标签库.我如何填写表格中的所有值?
javascript ×2
jquery ×2
apache ×1
encode ×1
highcharts ×1
html ×1
java ×1
json ×1
jsp ×1
servlets ×1
spring-mvc ×1