小编H.R*_*iee的帖子

另一个UIButton背景颜色问题

另一个简单的问题是改变UIButton的背景颜色.所以我在搜索之后想到一个常见的方法是创建图像或子视图.

我在故事板中创建了一个按钮并将其连接到插座.在我的VC课程中,我有以下内容

.H

@property (nonatomic, readwrite, strong) IBOutlet UIButton *uiLoginButton;
Run Code Online (Sandbox Code Playgroud)

.M

- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s and frame rect %@", __PRETTY_FUNCTION__, self.uiLoginButton); //here uiloginbutton does not have any size!

CGRect buttonRect = CGRectMake(50, 50, 100.0, 100.0);

self.uiLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.uiLoginButton.frame = buttonRect;
self.uiLoginButton.backgroundColor = [UIColor redColor];
NSLog(@"%s and frame rect %@", __PRETTY_FUNCTION__, self.uiLoginButton);    
}
Run Code Online (Sandbox Code Playgroud)

不,我已经随机设置了CGRectMake中的值,因为IBOutlet按钮的帧是0.为什么?

实际更改按钮颜色的正确方法是什么?

uibutton ios

5
推荐指数
1
解决办法
7920
查看次数

Ruby regexp返回""vs nil

以下正则表达式语句之间的不同结果背后的原因是什么:

"abbcccddddeeee"[/z*/] # => ""
Run Code Online (Sandbox Code Playgroud)

而这些回归nil:

"some matching content"[/missing/] # => nil
"start end"[/\Aend/] # => nil
Run Code Online (Sandbox Code Playgroud)

ruby regex

5
推荐指数
2
解决办法
1425
查看次数

@PreAuthorize with Bean in expression (Spring Boot)

简单的问题,我@Autowired在控制器中设置了一个 @Service 类。

试图在我的控制器中的一种方法上增加一点安全性。所以为了简单起见,我这样做是为了测试

@PreAuthorize("@myService.helloThere()")
public void someControllerMethod() {
    ...
}
Run Code Online (Sandbox Code Playgroud)

但真的没有成功。在方法调用期间出现异常。

java.lang.IllegalArgumentException:无法评估表达式“@myService.helloThere()”

我在这里遗漏了 EL 的东西吗?

更新

只需添加最后一个由异常引起的

引起:org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): 没有在上下文中注册的 bean 解析器来解析对 bean 'dummyServiceImpl' 的访问

现在我不明白为什么如果我使用 @Autowired 就不能在 StandardEvaluationContext 中访问它?

更新 2

由于我在自定义GlobalMethodSecurityConfiguration扩展类中连接了自己的角色层次结构,因此默认情况下DefaultMethodSecurityExpressionHandler没有applicationContext设置。我不确定为什么这是设计使然,或者我遗漏了一些明显的东西。我搜索了参考页面并找到了另一个帮助我解决问题的SO 线程。我正在发布更新的安全配置。

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class GlobalMethodSecurityConfig extends GlobalMethodSecurityConfiguration {

    @Autowired
    ApplicationContext applicationContext; //added this

    @Override
    protected MethodSecurityExpressionHandler createExpressionHandler() {           
        final DefaultMethodSecurityExpressionHandler handler = new DefaultMethodSecurityExpressionHandler();

        handler.setApplicationContext(applicationContext); //added this
        RoleHierarchyImpl roleHierarchy = new RoleHierarchyImpl(); …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot spelevaluationexception

5
推荐指数
1
解决办法
3272
查看次数

如何在JSP文件中提交和发送HTML表单的值到Servlet?

在用于Java的HTTP servlet中,我想提交一个表单.从输入字段中携带值的推荐方法是什么?它是使用隐藏的字段并通过request.getParameter(...)或与他们通过request.getAttribute(...)

html forms jsp servlets

2
推荐指数
1
解决办法
1万
查看次数