我想为Spring Boot项目添加基于方法的安全性.
似乎所有我需要是增加PermissionEvaluator和MethodSecurityExpressionHandler豆类,注释我WebSecurityConfigurerAdapter用@EnableGlobalMethodSecurity(prePostEnabled = true)和与方法@PreAuthorize("isAuthenticated() and hasPermission(#param, 'somePermissionName')").
但是在添加一个PermissionEvaluator豆之后
@Bean
public PermissionEvaluator permissionEvaluator() {
HelloPermissionEvaluator bean = new HelloPermissionEvaluator();
return bean;
}
Run Code Online (Sandbox Code Playgroud)
我得到一个IllegalArgumentException:"需要一个ServletContext来配置默认的servlet处理":
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping()] threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default …Run Code Online (Sandbox Code Playgroud) 当空白无关紧要时,表示可能非常重要.
在XML Schema Part 2:Datatypes Second Edition中,约束facet whiteSpace是为从字符串派生的类型定义的(http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace).如果此whiteSpace构面被替换或折叠,则在标准化期间可能会更改该值.
第4.3.6节末尾有一个注释:
这里使用的符号#xA(以及本说明书中的其他地方)表示通用字符集(UCS)代码点十六进制A(换行),其由U + 000A表示.此表示法与 区别开来,它是对同一UCS代码点的XML字符引用.
如果元素elem的数据类型具有空格约束折叠,则"<elem> text </elem>"应该变为"text"(删除前导和尾随空格),但"<elem> text </elem>"应该变为" text "(由字符引用编码的空格不被删除).
因此,解析器/树构建器可以处理此规范化,也可以在之后完成.
set_whitespace_normalization('./country/neighbor', 'collapse')吗?normalize(content)解析器或树构建器中是否有钩子?elem.original_text,可能会返回"  text "?elem.unnormalized_text,可能会返回" text "?我想使用Python的xml.etree.ElementTree,但我会考虑任何其他XML库来完成这项工作.
当然,通过使用字符引用声明空白无关紧要(替换或折叠)然后作弊是不好的风格.在大多数情况下,应该更改数据或模式以防止这种情况,但有时您必须使用外部XML模式和 …
我被困在这里尝试不转义HTML特殊字符。
有问题的文字是
Rudimental & Emeli Sandé
Run Code Online (Sandbox Code Playgroud)
应该转换为 基本&EmeliSandé
文本是通过WGET下载的(在Python外部)
要对此进行测试,请在此行中保存一个ANSI文件并导入。
import HTMLParser
trackentry = open('import.txt', 'r').readlines()
print(trackentry)
track = trackentry[0]
html_parser = HTMLParser.HTMLParser()
track = html_parser.unescape(track)
print(track)
Run Code Online (Sandbox Code Playgroud)
当一行中有é时,我会收到此错误。
*pi@raspberrypi ~/scripting $ python unparse.py
['Rudimental & Emeli Sand\xe9\n']
Traceback (most recent call last):
File "unparse.py", line 9, in <module>
track = html_parser.unescape(track)
File "/usr/lib/python2.7/HTMLParser.py", line 472, in unescape
return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s)
File "/usr/lib/python2.7/re.py", line 151, in sub
return _compile(pattern, flags).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte …Run Code Online (Sandbox Code Playgroud) character-encoding html-parsing python-2.7 raspberry-pi python-unicode
我可以用自定义符号替换传统的HTML复选框符号"unchecked","checked"和"indeterminate":
<link rel="stylesheet"
href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<style type="text/css">
input[type="checkbox"] {
display: none;
}
input[type="checkbox"]+label:before {
font-family: FontAwesome;
content: "\f096"; /* fa-square-o */
}
input[type="checkbox"]:checked + label:before {
content: "\f046"; /* fa-check-square-o */
}
input[type="checkbox"]:indeterminate + label:before {
content: "\f0c8"; /* fa-square */
color: grey;
}
</style>
...
<input type="checkbox" id="cb1" />
<label for="cb1"> label text</label>
Run Code Online (Sandbox Code Playgroud)
请参阅http://plnkr.co/SPvN1xEkQqcFcYbxWur2
除了键盘导航和控制之外,这种方法很有用.使用传统的复选框,您可以[TAB]通过输入元素和链接,并使用[SPACE]和[ENTER]访问它们.自定义符号使用display:none,这似乎禁用了这些元素的键盘控制.
如何为这些自定义复选框重新启用键盘控制?
checkbox ×1
css ×1
elementtree ×1
html ×1
html-parsing ×1
java ×1
keyboard ×1
python ×1
python-2.7 ×1
raspberry-pi ×1
spring ×1
spring-boot ×1
whitespace ×1
xml ×1
xsd ×1