我正在使用 NestJs。我在控制器中使用拦截器进行 PUT 请求。
我想在 PUT 请求之前更改请求正文,并且我想更改由 PUT 请求返回的响应正文。如何做到这一点?
在 PUT 中使用
@UseInterceptors(UpdateFlowInterceptor)
@Put('flows')
public updateFlow(@Body() flow: Flow): Observable<Flow> {
return this.apiFactory.getApiService().updateFlow(flow).pipe(catchError(error =>
of(new HttpException(error.message, 404))));
}
Run Code Online (Sandbox Code Playgroud)
拦截器
@Injectable()
export class UpdateFlowInterceptor implements NestInterceptor {
public intercept(_context: ExecutionContext, next: CallHandler): Observable<FlowUI> {
// how to change request also
return next.handle().pipe(
map(flow => {
flow.name = 'changeing response body';
return flow;
}),
);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一种表单,选项卡上的按键字段应该是焦点旋转清晰的。请看下面的代码。
$('#e').keyup(function (e) {
if (e.which === 9)
$("#a").focus();
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input type = "text" id = "a" name="a" /><br/>
<input type = "text" id = "b" name="b" /><br/>
<input type = "text" id = "c" name="c" /><br/>
<input type = "text" id = "d" name="d" /><br/>
<input type = "text" id = "e" name="e" /><br/>Run Code Online (Sandbox Code Playgroud)
当它转到字段“e”时,它直接转到“a”,这是可以的。但它不会在“e”处等待,无需有机会进入“e”字段
请指导我。
我有单选按钮.
<div>
<input type="radio" name="ticket" value="Standard"> Standard
<input type="radio" name="ticket" value="Express"> Express
<input type="radio" name="ticket" value="Priority"> Priority
<input type="radio" name="ticket" value="Overnight"> Overnight
</div>
Run Code Online (Sandbox Code Playgroud)
我想使用JavaScript将其转换为滑块选择.有点像,
我在网上做了很多研究,发现了js滑块
但是它不提供选择(断点)选项.
而且,我经历了
<input type="range" id="myRange" value="90">
Run Code Online (Sandbox Code Playgroud)
但不知道我怎么能达到只有很少值不完全滑块的范围.
我HashMap在 Java 中有两个。
第一个包含一个键和它的值。其中 second 包含该键的评估索引(顺序)。我想通过参考第二张地图对第一张地图进行排序。
第一个哈希映射 <key, value>
<"C","ccc">
<"D","ddd">
<"A","aaa">
<"B","bbb">
Run Code Online (Sandbox Code Playgroud)
第二个哈希映射 <key, value>
<"0","A">
<"1","B">
<"2","C">
<"3","D">
Run Code Online (Sandbox Code Playgroud)
结果应该是
<"A","aaa">
<"B","bbb">
<"C","ccc">
<"D","ddd">
Run Code Online (Sandbox Code Playgroud)
循环这两个映射并检查比较键很简单但效率不高。任何有效的想法?
我有一个具有完全限定异常名称的字符串变量。我想检查 catch 块是否发生异常,无论它是否是字符串中提到的异常实例。怎么解决
String stringEx = "org.hibernate.StaleStateException";
try {
// program
} catch (Exception ex) {
if (e instanceof stringEx) { //<-- How to convert string to exception class
// do specific process
}
}
Run Code Online (Sandbox Code Playgroud)