我有一点麻烦阻止div闪存,其中反应将呈现错误消息,然后接收道具,最后渲染道具.
在我的EventsView组件中,我有以下内容.
view.js
var view;
if (_.size(this.props.events) !== 0) {
view = this.props.events.map(function(year) {
return <YearView year={year} />;
});
} else {
view = <NoEventsView />
}
Run Code Online (Sandbox Code Playgroud)
所以变量view被渲染,最初没有this.props.events页面加载,因为我有另一部分文件创建它.创建this.props.events时,将呈现事件.这是通过react.Backbonemixin 完成的.
我尝试过使用一些组件生命周期方法,比如componentWillUpdate.问题是他们似乎不希望以我希望它们工作的方式工作,并且永远不会呈现错误消息.我在下面尝试过的例子(以及其他)
我想做这样的事情.
view.js
componentWillUpdate: function(nextprops, nextstate) {
if (_.size(nextprops.events) !== 0) {
var view = nextprops.events.map(function(year) {
return <YearView year={year} />;
});
this.setState({
view: view
});
} else {
this.setState({
view: <NoEventsView />
})
}
},
// render this.state.view
Run Code Online (Sandbox Code Playgroud)
然后我会设置getInitialState:view …
这个问题似乎已被多次询问,但我检查的所有解决方案都还没有为我工作.我在nginx安装了Django 1.6.1的Ubuntu 14.04服务器上运行.我正在尝试将默认的django管理员后端用于项目(通常在localhost/admin /).
我遇到的问题是 OperationalError at /admin/ attempt to write a readonly database
(更改当我更改db.sqlite3文件的chmod权限时,错误现在读取OperationalError at /admin/ unable to open database file 但我已经检查了Django Newbie Mistakes网站上的每个选项以获得答案而没有骰子)
一些答案谈到了生成的数据库文件的r + w + x权限,db.sqlite3据我所知甚至777在db文件中没有做任何事情所以我保留了它656.
至于我可以告诉django项目的工作找到(所有页面呈现正常,/ admin页面呈现没有CSS.当我尝试使用localhost/admin /登录并单击提交时,我得到带有错误的django调试页面).他们都归root:root.我已经尝试更改每个文件和目录的权限,www-data:www-data但没有.
我甚至尝试更改settings.py以获得db的绝对路径而不是 os.path.join(BASE_DIR, 'db.sqlite3')
我认为这归结为所有权问题但我会提供任何帮助.
我一直在Spring Security + Webflux中使用ReactiveAuthenticationManager。它是经过自定义的,以返回一个实例UsernamePasswordAuthenticationToken,从该实例中我可以看出是调用时应接收的内容ReactiveSecurityContextHolder.getContext().map(ctx -> ctx.getAuthentication()).block()。据我所知,我无法通过两种方式访问身份验证上下文:
SecurityContextHolder.getContext().getAuthentication();
Run Code Online (Sandbox Code Playgroud)
要么
ReactiveSecurityContextHolder.getContext().map(ctx -> ctx.getAuthentication()).block()
Run Code Online (Sandbox Code Playgroud)
尝试从控制器或组件访问这些文件将解决null。对于我是否真的要Authentication在自定义管理器中返回实例,我有些怀疑,好像我是:
@Override
public Mono<Authentication> authenticate(final Authentication authentication) {
if (authentication instanceof PreAuthentication) {
return Mono.just(authentication)
.publishOn(Schedulers.parallel())
.switchIfEmpty(Mono.defer(this::throwCredentialError))
.cast(PreAuthentication.class)
.flatMap(this::authenticatePayload)
.publishOn(Schedulers.parallel())
.onErrorResume(e -> throwCredentialError())
.map(userDetails -> new AuthenticationToken(userDetails, userDetails.getAuthorities()));
}
return Mono.empty();
}
Run Code Online (Sandbox Code Playgroud)
和PreAuthentication的实例在哪里扩展AbstractAuthenticationTokenAuthenticationTokenUsernamePasswordAuthenticationToken
有趣的是,尽管ReactiveSecurityContextHolder.getContext().map(ctx -> ctx.getAuthentication()).block()在控制器中不起作用,但我可以@AuthenticationPrincipal在控制器中成功地将带有注释的身份验证主体作为方法参数注入。
这似乎是一个配置问题,但我不知道在哪里。有人知道为什么我不能返回身份验证吗?
我打算修改特定字符串的每个其他字母.但就本计划而言,这一切都不会发生.到目前为止,我已经从用户那里抓取了一个字符串并将其存储userinput并打算打印出来.
#include <stdio.h>
#include <string.h>
int main(void) {
char userinput[256] ="";
printf("Enter somthing to change:\n");
scanf("%s", &userinput);
printf("%s\n", userinput);
int k = 2; // This is just here to do something every time k is even
int j = strlen(userinput);
for (int i = 0; i < j; i++) {
if(k % 2 == 0) {
printf("%s", userinput[i]);
k++;
}
else {
printf("%s", userinput[i]);
k++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
strlen()但是该功能不起作用userinput.我strlen()认为这是因为应该获取字符串的第一个字符的地址然后迭代直到达到空字符,但scanf实际上不创建空字符.'\0'在没有先知道字符串的长度的情况下,我无法想出一种在字符串后添加字符串的方法.
如果存储在数组中,我将如何访问存储的字符序列的长度?
一个非常简单的mmap写入for循环.我试图做的只是使每个字节的值为255.
#include <stdio.h>
#include <sys/mman.h>
#include <stdint.h>
#define BUFFER_SIZE 1024
int main()
{
void *Buffer = mmap(0,
BUFFER_SIZE,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0);
uint8_t *Byte = (uint8_t *)Buffer;
for (int i = 0; i < BUFFER_SIZE - 1; ++i)
{
*Byte++ = 0xFF;
printf("%u", *Byte);
}
munmap(Buffer, BUFFER_SIZE);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我的输出全是0.我错过了什么?