这个问题今天来到我身边.我正在使用包含大量JSP的基于Web的(Struts 2)项目,并且大多数input, select, table和a元素仅使用name属性定义,没有id设置,例如:
<input name="myname" class="myclass" value="" type="text"/>
到目前为止一切都那么好,除了不幸的是这些字段有很多javascript验证,并且我可以在离开大多数代码之前阅读代码实际上引用了元素document.getElementById.
这里的问题是,这是一个旧的应用程序(实际上不是那么老)只与IE-6和IE-7兼容(我没有搜索网络,以了解IE实际上似乎只找到了元素与name属性,但我想它必须做点什么).每个其他单一浏览器都抱怨和哭泣并不奇怪.
所以,我正在尝试提出一个简单的解决方案:查找所有使用该属性定义input, select, table和a元素的JSP,name但不是id为了修复HTML.
使用我的好朋友http://rubular.com我想出了以下内容:
/<(?:(input|select|a|table))\s+((?!id).)*>
这将捕获每个被引用的元素id.但是,我怎么能断言只有那些name匹配的?
哦,另一个重点.元素的定义是一行的,所以最有可能的是:
<input name="..."
class="..."/>
Run Code Online (Sandbox Code Playgroud) Go 中是否有执行无符号移位(即无符号右移)操作?Java 中是这样的
0xFF >>> 3
Run Code Online (Sandbox Code Playgroud)
关于此事我唯一能找到的就是这篇文章,但我不确定我必须做什么。
提前致谢。
我正在尝试调整我的应用程序配置以设置ETag支持.
我刚刚检查了这个问题,所以让我说一下我的代码与它的不同之处:
WebConfig看起来像这样:
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = { "xxx", "yyy" })
public class WebConfig extends WebMvcConfigurerAdapter {
@Bean
public Filter shallowETagHeaderFilter() {
return new ShallowEtagHeaderFilter();
}
...
}
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
...
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint())
.and().authorizeRequests()
.antMatchers(HttpMethod.GET, "/**").authenticated()
.antMatchers(HttpMethod.POST, "/**").authenticated()
.antMatchers(HttpMethod.HEAD, "/**").authenticated()
.and().csrf().disable()
.addFilterBefore(authenticationTokenProcessingFilter(), UsernamePasswordAuthenticationFilter.class);
}
}
@Order(value=1)
public class SecurityWebAppInitializer extends AbstractSecurityWebApplicationInitializer {
}
我没有看到任何地方ShallowEtagHeaderFilter被添加到默认链或任何东西,我如何在此设置中使用它?
我试图更多地了解go的频道和goroutines,所以我决定制作一个小程序来计算文件中的单词,由bufio.NewScanner对象读取:
nCPUs := flag.Int("cpu", 2, "number of CPUs to use")
flag.Parse()
runtime.GOMAXPROCS(*nCPUs)
scanner := bufio.NewScanner(file)
lines := make(chan string)
results := make(chan int)
for i := 0; i < *nCPUs; i++ {
go func() {
for line := range lines {
fmt.Printf("%s\n", line)
results <- len(strings.Split(line, " "))
}
}()
}
for scanner.Scan(){
lines <- scanner.Text()
}
close(lines)
acc := 0
for i := range results {
acc += i
}
fmt.Printf("%d\n", acc)
Run Code Online (Sandbox Code Playgroud)
现在,在大多数示例中,我发现到目前为止,lines和results通道都将被缓冲,例如 …
我有两个清单:
List x = [1, 2, 5, 7, 8];
List y = [1, 3, 4, 5];
Run Code Online (Sandbox Code Playgroud)
我试图获得以下计算的不对称差异:
x - y (what's in x that's not in y) => 2 7 8
y - x (what's in y that's not in x) => 3 4
Run Code Online (Sandbox Code Playgroud)
我正在尝试实现的正是guava的Sets.difference所提供的,除了我坚持使用Java 1.4(我很容易将我的实现从使用Lists更改为Sets)
使用Collection.removeAll/retainAll将是一个交易破坏者,因为这些方法就地工作.我在列表中保存的对象是一些实际映射到Hibernate的重POJOS.
底线是,是否有类似Java 1.4的Sets实用程序类?或者可以计算两个集合的不对称差异的东西?
go ×2
annotations ×1
asymmetric ×1
channels ×1
collections ×1
etag ×1
goroutine ×1
guava ×1
html ×1
java ×1
regex ×1
set ×1
spring ×1
spring-boot ×1
tags ×1
validation ×1