我一直在反对这个问题已经有一段时间了:我想要捕获所有[a-z]+[0-9]?字符序列,不包括字符串sin|cos|tan等等.所以完成了我的正则表达作业,以下正则表达式应该有效:
(?:(?!(sin|cos|tan)))\b[a-z]+[0-9]?
Run Code Online (Sandbox Code Playgroud)
正如你看到我使用负前瞻与交替沿-在\b非捕获组右括号之后关键是要避免匹配in的sin等正则表达式有意义,因为事实上我与使用RegexBuddy和Java尝试它作为目标实现并获得想要的结果,但它不能使用Java Matcher和Pattern对象!有什么想法吗?
干杯
我正在尝试使Spring Security 3.05与修改后的UserDetailsContextMapper一起工作,以便我可以从他们需要的方式获取更多信息,这项任务似乎相当简单,但没有成功.
我已将Spring Security配置为使用以下bean的LDAP身份验证:
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldaps://192.168.1.102:636" />
<property name="userDn" value="manager" />
<property name="password" value="password" />
</bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource" />
<property name="userSearch">
<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="" />
<constructor-arg index="1" value="(mail={0})" />
<constructor-arg index="2" ref="contextSource" />
</bean>
</property>
</bean>
</constructor-arg>
<property name="userDetailsContextMapper" ref="myContextMapper" />
</bean>
Run Code Online (Sandbox Code Playgroud)
然而即使我已经定义myContextMapper为:
<bean id="myContextMapper" class="com.mypackage.MyLDAPUserDetailsMapper">
<property name="rolePrefix" value="TEST_PREFIX" />
</bean>
Run Code Online (Sandbox Code Playgroud)
这是行不通的.意味着忽略了自定义映射器(我没有得到任何调试输出).
ps applicationContext-security.xml可以在下面看到,除了被忽略的自定义UserDetailsMapper,身份验证和角色分配工作正常.
<authentication-manager>
<ldap-authentication-provider server-ref="contextSource"/>
</authentication-manager>
Run Code Online (Sandbox Code Playgroud) 我使用的是Spring 3.0.6,我有一个控制器用于将文件上传到服务器.我正在使用脚本使用XmlHttpRequest上传支持它的浏览器,而其他浏览器提交(隐藏)多部分表单.但问题是,当提交表单时,它会发送以下标题:
Accept text/html, application/xhtml+xml, */*
Run Code Online (Sandbox Code Playgroud)
我认为由于此标头,标有@ResponseBody响应回复的Controller 已转换为XML而不是JSON.有没有办法在不破解表单提交请求的情况下解决这个问题?
我之前已经问过这个问题但没有得到答案所以我正在添加更多信息.我使用spring 3 mvc和spring security进行身份验证/授权,构建了一个对js有点沉重的在线服务.HTTPS是任何交互的要求,因此所有请求都是这样.服务器设置包含一个Apache服务器后面的一个Tomcat 7应用服务器(可能在将来添加更多),该服务器充当mod_proxy,mod_cache和mod_deflate的反向代理.为所有可缓存资源(js,css,images)设置缓存标头:
Cache-Control:max-age=604800, must-revalidate, public
Run Code Online (Sandbox Code Playgroud)
上面的标题在Firefox和IE浏览器中都有所需的结果(至少分别是我测试过的3+和8+版本),即两个浏览器都相应地缓存.js和.css文件,除非用户刷新页面以便浏览器将附加到请求标头a Cache-Control:max-age=0并将获得304回复,或强制刷新,Cache-Control:no-cache以便它将重新获取资源.另一方面,谷歌浏览器的行为有所不同,虽然它通过将jsessionid附加到用于在缓存中存储文件的密钥来缓存文件,将它绑定到分配给用户的特定会话.这导致每次用户登录/注销或关闭浏览器时都从服务器重新获取文件(Spring安全性具有临时会话和不同的记忆我).当用户访问登录屏幕并且在登录后将其重定向到主站点时,用于登录屏幕以及主站点的主要css甚至被提取两次(因为现在chrome将文件放入缓存中没有sessionid绑定到它).
我有一个服务bean(使用@Service注释),它实现了扩展ApplicationEvent抽象类的T类型事件对象的ApplicationListener接口.还有就是这个在Spring文档一个非常简单和明显的例子在这里
但是,当我尝试使用@Autowired将此bean注入其他的时,我得到的是:
org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项找到类型[...]的匹配bean:预期至少有一个bean可以作为此依赖项的autowire候选者.依赖注释{@ org.springframework.beans.factory.annotation.Autowired(required = true)}
如果我尝试使用类似@Resource的东西,那么我会得到一个类强制转换异常(尝试注入一种类型的资源但获得代理).