我想为无法识别的字段和请求正文的其他错误设置自定义错误消息。我尝试了 ExceptionMapper 但它不起作用:/使用 quarkus 和 Jackson
public class ReqDTO {
private String a;
}
Run Code Online (Sandbox Code Playgroud)
发送请求时:
{
"a": "a"
}
Run Code Online (Sandbox Code Playgroud)
它看起来不错。但是发送时:
{
"a": "a",
"b": "b"
}
Run Code Online (Sandbox Code Playgroud)
有错误响应:
Unrecognized field "b"; (class ReqDTO), not marked as ignorable
Run Code Online (Sandbox Code Playgroud)
想要自定义此消息和其他错误的 json 正文(如太多字段)以拥有“BAD_JSON_SCHEMA”等消息。
尝试过
@Provider
public class ExHandler implements ExceptionMapper<JsonMappingException>{
public Respone toResponse(JsonMappingException e) {
//response bad field impl
}
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。看起来像 json 处理异常更快。尝试使用“Exception”、“JsonParseException”但没有任何改变:/
@Path("/")
public class Controller {
@Post
@Consume(APPLICATION_JSON)
@Produces(TEXT_PLAIN)
public Response getA(@Valid ReqDTO reqDTO){
//logic
}
}
Run Code Online (Sandbox Code Playgroud)
@编辑
找到类似 DeserializationProblemHandler 的东西,但不知道如何更改 …
我有一个片段可以滑动到屏幕高度的 0.3...现在我想在按钮上将其从 0.3 动画到 0.8。但怎么办呢?我可以为布局权重设置动画吗?单击按钮后我需要显示更多信息,说明为什么要升高高度。objectAnimator 不起作用。
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:gravity="bottom">
<LinearLayout
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:animateLayoutChanges="true"
android:background="@drawable/shape_details"
android:clickable="true"
android:orientation="vertical"
android:padding="15dp"
android:paddingBottom="32dp"
android:paddingTop="32dp">
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text=""
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight=".1"
android:src="@drawable/time" />
<TextView
android:id="@+id/time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".9"
android:text="TextView"
android:textColor="@android:color/darker_gray"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)