是否可以使用浏览器控制台、开发人员工具或命令来了解运行 Javascript Web Workers 的概述?
我使用一个使用工作人员的外部库并希望确保它正确运行,但我不知道如何调用工作人员并且没有指向它的变量。
我有问题,我想将我的Spring WebMVC应用程序的一些进程外包到单独的Threads中.这很容易并且有效,直到我想使用一个使用全局请求的类userRightService.这在线程中不可用,我们遇到了一个问题,这几乎是可以理解的.
这是我的错误:
java.lang.RuntimeException:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'scopedTarget.userRightsService': Scope 'request' is not active
for the current thread; consider defining a scoped proxy for this bean if
you intend to refer to it from a singleton; nested exception is
java.lang.IllegalStateException: Cannot ask for request attribute -
request is not active anymore!
Run Code Online (Sandbox Code Playgroud)
好的,够清楚了.我试图通过实现此解决方案来保持请求上下文:
这是我的runnable类:
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class myThread implements Runnable {
private RequestAttributes context;
public DataExportThread(RequestAttributes context) {
this.context = context;
}
public …Run Code Online (Sandbox Code Playgroud) 我的 jasmine2/protractor 测试看起来像这样
var testUserId = null;
describe("user test", function() {
beforeAll(function(done) {
createTestUser().
.then(function(userId){testUserId = userId})
.then(done)
.catch(done.fail);
it("should do stuff with the test user", function(done) {
// bla bla
});
afterAll(function(done) {
deleteTestUser(testUserId).
.then(done)
.catch(done.fail);
});
})
Run Code Online (Sandbox Code Playgroud)
createTestUser 和 deleteTestUser 返回承诺。如果出现问题,他们会拒绝并显示错误消息。可能现在的问题是,即使在 beforeAll 中发生错误,测试也会开始。我得到
Failures:
1) should do stuff with the test user
Message: [my error message from beforeAll]
Run Code Online (Sandbox Code Playgroud)
如果有很多测试,它会尝试执行所有测试并失败并显示非常相同的错误消息。如果 beforeAll 函数失败,是否可以阻止它执行测试?
谢谢!
(“茉莉花核心”:“2.8.0”,“量角器”:“5.2.1”)
编辑:
这不完全是我所要求的,但至少我找到了一个解决方案来保持错误消息的数量,如下所示:
var testUserId = null;
describe("user test", function() {
beforeAll(function(done) {
createTestUser().
.then(function(userId){testUserId = …Run Code Online (Sandbox Code Playgroud) 我目前在组件的方法对象中有这段代码:
startImageAnimation() {
$('.splash-image').fadeIn(1400, () => {
setTimeout(function() {
$('.splash-image').fadeOut(1400, () => {
setTimeout(() => {
$('.splash-screen').fadeOut(600);
});
});
}, 1000);
});
},
Run Code Online (Sandbox Code Playgroud)
我真的试图使用 Vue 转换找到一种方法,但是对于使用 jQuery 做这么简单的事情来说,它看起来太难了。
这里真正的问题是:我应该仍然像这样编码还是应该在这些情况下采取不同的方法?对于 jQuery animate() 或任何其他方法,jQuery 比纯 JS 更容易做到的事情也是如此。
谢谢!
我的网络服务生成并返回一个 .tex 文件。我想在 http 标头中给出正确的 mimetype。
除了在这里我找到的以外,我没有找到那么多application/x-tex。这是一个值得坚守的权威吗?
我需要执行一些脚本操作,这可能需要一段时间(比如可能一分钟).在这些操作开始时,我从MySQL数据库中采取了一些措施,重要的是它们在操作完成之前不会更改.数据库有几十个表,因为它属于一个非常老式但却很庞大的CMS,CMS用户有十几个选项来修改它.
我自己甚至不想在我的脚本在DB中运行时更改任何内容,它只是被冻结.这不是转储或更新.但是表格应该保持开放以供所有人阅读,以防止所连接主页的访问者收到错误.
如果数据库更改操作(同时可能由其他CMS用户执行)将在DB再次解锁后触发,那将是完美的,但如果它们失败,我不介意.
所以我想在脚本的开头我把表锁定了
lock first_table write;
lock second_table write;
...
Run Code Online (Sandbox Code Playgroud)
在我做完之后
unlock tables
Run Code Online (Sandbox Code Playgroud)
我认为这应该完全符合我的要求.但是我可以为db的所有表存档这些而不明确命名它们,以使其更具未来性吗?
这不能确定:
lock tables (select TABLE_NAME from information_schema.tables
where table_schema='whatever') write;
Run Code Online (Sandbox Code Playgroud)
另一个问题是,如果有人可以动态回答这个问题,那么我是否必须使用另一个MYSQL用户来锁定/解锁,而不是CMS使用的用户.如果我理解这一点,那么是的.
从 Angular 7 更新到 Angular 8 后,我遇到了一些问题。
ng --version
Angular CLI: 8.3.22
Node: 10.18.1
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.22
@angular-devkit/build-angular 0.803.22
@angular-devkit/build-optimizer 0.803.22
@angular-devkit/build-webpack 0.803.22
@angular-devkit/core 8.3.22
@angular-devkit/schematics 8.3.22
@angular/cdk 8.0.2
@angular/cli 8.3.22
@angular/flex-layout 8.0.0-beta.27
@angular/material 8.0.2
@ngtools/webpack 8.3.22
@schematics/angular 8.3.22
@schematics/update 0.803.22
rxjs 6.4.0
typescript 3.4.5
webpack 4.39.2
Run Code Online (Sandbox Code Playgroud)
这是我的 package.json:
"dependencies": {
"@angular/animations": "^8.0.0",
"@angular/cdk": "~8.0.0",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": …Run Code Online (Sandbox Code Playgroud) 当我构建我的Promise并调用失败函数时,错误应该被承诺的.catch函数捕获吗?但是在console.log中我仍然认为它没有被捕获(也是.catch函数被触发).为什么?或者这是打算?我想我从概念上得到了一些错误,并希望得到启发!
请考虑以下示例:
var A = {
loadingPromise: null,
loadingPromiseFail: null,
loadingPromiseResolver: null,
init: function() {
this.loadingPromise = new Promise(
function(resolve, fail) {
this.loadingPromiseResolver = resolve;
this.loadingPromiseFail = fail;
}.bind(this)
);
this.loadingPromise.then(function(data) {
console.log('success');
}.bind(this));
this.loadingPromise['catch'](function(e, x) {
console.log('error', e);
}.bind(this));
},
doSomething: function() {
setTimeout(function(){
this.loadingPromiseFail('404');
}.bind(this), 1000);
}
}
A.init();
A.doSomething();
Run Code Online (Sandbox Code Playgroud)
的console.log:
error 404
uncaught exception: 404
Run Code Online (Sandbox Code Playgroud)
为什么是第二个?
我使用 Jsoup 和OpenHTMLToPDF从 HTML 创建了一个 PDF 。我必须在我的 PDF 中使用不同的字体才能覆盖非拉丁字形(请参阅此处)。如何正确嵌入我的字体?
src/main/resources/test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Font Test</title>
<style>
@font-face {
font-family: 'source-sans';
font-style: normal;
font-weight: 400;
src: url(fonts/SourceSansPro-Regular.ttf);
}
</style>
</head>
<body>
<p style="font-family: 'source-sans',serif">Latin Script</p>
<p style="font-family: 'source-sans',serif">????? ???????? ???????.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
src/main/java/main.java:
import com.openhtmltopdf.extend.FSSupplier;
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
import org.jsoup.Jsoup;
import org.jsoup.helper.W3CDom;
import org.w3c.dom.Document;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
public class main {
public static void main(String[] …Run Code Online (Sandbox Code Playgroud) 我做了一个简单的 servlet 过滤器来减慢我的应用程序的响应速度:
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class DelayFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
Integer seconds = 10;
try {
Thread.sleep(seconds * 1000);
} catch (InterruptedException e) {
throw new ServletException("Interrupted!");
}
HttpServletResponse response = (HttpServletResponse) resp;
response.setHeader("Cache-Control", "no-cache, must-revalidate");
chain.doFilter(req, resp);
}
@Override
public void destroy() {}
}
Run Code Online (Sandbox Code Playgroud)
我读了一堆文章,为应用程序注册它是这样的:在此处输入链接描述 通常有两种注册方法,一种用于使用web.xml,一种用于编程配置。我必须使用的应用程序不使用 XML,但也没有任何初始化程序类。配置是使用 Config Class 完成的,如下所示:
@Configuration
@EnableWebMvc …Run Code Online (Sandbox Code Playgroud) javascript ×4
java ×3
spring ×2
spring-mvc ×2
angular ×1
e2e-testing ×1
fonts ×1
jasmine ×1
jquery ×1
jsoup ×1
mime-types ×1
mysql ×1
pdfbox ×1
promise ×1
protractor ×1
servlets ×1
transition ×1
vue.js ×1
vuejs2 ×1
web-worker ×1