我寻找答案,但没有找到。如果我在spring-security.xml<intercept-url pattern="/test*" access="ROLE_USER" />中添加,一切都会按预期进行。<form-login>但如果我想@RolesAllowed("ROLE_ADMIN")执行该方法:
@RolesAllowed("ROLE_ADMIN")
@RequestMapping(value="/test", method = RequestMethod.GET)
public String test() {
return "test";
}
Run Code Online (Sandbox Code Playgroud)
如果 spring-security.xml 看起来像这样(启用了 jsr250 注释):
<http auto-config="true">
<form-login login-page="/login.html"
default-target-url="/welcome.html"
authentication-failure-url="/loginfailed.html" />
<logout logout-success-url="/logout.html" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="john" password="doe" authorities="ROLE_ADMIN" />
<user name="jane" password="doe" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<global-method-security secured-annotations="enabled" jsr250-annotations="enabled" />
Run Code Online (Sandbox Code Playgroud)
好吧,在这种情况下,John 和 Jane 都可以访问测试页。我想我错过了一些基本的东西,我们将不胜感激。
Java文档说:
作为一种风格问题,程序员应该始终在最有效的嵌套元素上使用此注释.如果要在特定方法中禁止警告,则应该注释该方法而不是其类.
我并没有真正感受到使用此注释的任何好处.但它到处都不是很难.我应该将它用于与Hibernate交互的dao类的所有方法(获取并保存一些数据)吗?
这是关于Java的一个非常基本的问题.我已经读过某个地方,首先在子类的构造函数中隐式调用超类的构造函数.但我找不到文档的参考,详细阅读.有人可以提供这个参考吗?
这是我正在谈论的一个例子,它输出super sub字符串:
class SuperClass {
static String s = "";
protected SuperClass() { s += "super "; }
}
public class SubClass extends SuperClass {
private SubClass() { s += "sub"; }
public static void main(String[] args) {
new SubClass();
System.out.println(s);
}
}
Run Code Online (Sandbox Code Playgroud) 这是一个基本问题,我对maven多模块结构并不熟悉.说,我有一个Web应用程序.我想将一些模块连接到它(一些服务).我是否需要创建一个Web应用程序只是其中一个模块,依赖于其他模块,然后运行它?起初我以为我可以运行整个项目,但是这个选项在我的IDE中变得不活跃(我现在正在使用NetBeans),这让我觉得我应该运行类似主模块(在这种情况下是一个Web应用程序) ).是这样吗?提前致谢.