angularjs - 解决了 Handler 执行引起的异常
问题描述
处理程序执行导致的已解决异常:org.springframework.http.converter.HttpMessageNotReadableException:无法读取文档:无法反序列化 java.lang.String[] 的实例超出 VALUE_STRING 令牌
2019-02-26 13:47:12.697 WARN 2510 --- [nio-9009-exec-8] .wsmsDefaultHandlerExceptionResolver:无法读取 HTTP 消息:org.springframework.http.converter.HttpMessageNotReadableException:无法读取文档:不能从 VALUE_STRING 令牌中反序列化 java.lang.String[] 的实例
在 [来源:(PushbackInputStream);行:1,列:83](通过参考链:ru.valyaeva.marathon.model.User["roles"]);嵌套异常是 com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize an instance of java.lang.String[] out of VALUE_STRING token
在 [来源:(PushbackInputStream);行:1,列:83](通过参考链:ru.valyaeva.marathon.model.User["roles"])
使用 angularjs 时出现此错误,我尝试在作为数组的角色字段中将值作为数组传输,但有些地方不正确
<div class="bloc" >
<select ng-model="user.roles">
<option value= {"ROLE_USER"}>ROLE_USER</option>
<option value= {"ROLE_SUPPORT"} >ROLE_SUPPORT</option>
<option value={"ROLE_ADMIN"} >ROLE_ADMIN</option>
</select>
</div>
我只是无法将此值传递到此字段,也许我错误地传递了要保存在角色字段中的值?
解决方案
<div class="bloc" >
<select ng-model="role" ng-change="selectRole()">
<option ng-value="ROLE_USER">ROLE_USER</option>
<option ng-value="ROLE_SUPPORT">ROLE_SUPPORT</option>
<option ng-value="ROLE_ADMIN">ROLE_ADMIN</option>
</select>
$scope.role = undefined;
$scope.selectRole = function() {
$scope.user.roles = [$scope.role];
}
这解决了我的错误
推荐阅读
- google-apps-script - ReferenceError: Jdbc is not defined,V8版本问题?
- c# - 我的 TCP 客户端没有连接到我的 TCP 服务器
- php - 如何从 php 中的现有数组创建一个新数组?
- xpath - 如何使用翻滚窗口按内容对 XML 元素进行分组?
- php - php Json删除键的双引号以及如何更改键的名称
- python - 由于 tf.keras.preprocessing.text.Tokenizer.texts_to_sequences 上的 np.hstack 导致维度(形状)发生变化
- laravel - 使用相同的键值合并集合
- python - 为什么我的冒泡排序不能正常工作?
- javascript - 以度为单位从航向获取左侧或右侧位置
- php - PHP curl 行为不一致