【发布时间】:2014-11-20 03:01:15
【问题描述】:
我从客户端的用户那里得到一些输入,没有字符限制。所以我将输入存储为 BLOB 数据类型。
我直接使用 getter 和 setter 填充我的实体。
动作类:
public class OperatorNotesAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private OperatorNotesInfo note;
....
}
OperatorNotesInfo 是我想要填充的实体。在客户端,我使用 JavaScript 将用户填写的输入发送到操作类:
JS:
$.ajax({
type: 'POST',
url: "<s:url action='updateNote'/>",
data:
{
'note.title':$('#title').val(),
'note.id.operatorId':$('#operatorId').val(),
'note.content':$('textarea').val()
},
这里的内容是动作类中的字节数组类型,因为它存储为 BLOB。
如何将用户输入的输入转换为字节数组,以便保存实体note的内容属性?
【问题讨论】:
-
你想从字符串转换为字节数组?
-
你有没有试过用谷歌搜索如何在java中将字符串转换为字节数组?
-
谷歌搜索或只是 Stackoverflowing :P
标签: javascript java jsp struts2 type-conversion