我试图用单引号替换字符串中的所有双引号.在这里我的表达:
echo "<a href=\"#\" id=\"resendActivationMailLink\">here</a>" | sed "s/\"/'/"
Run Code Online (Sandbox Code Playgroud)
不幸的是,只有第一个双引号被替换:S
<a href='#" id="resendActivationMailLink">here</a>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Spring安全性中有多个身份验证提供程序的引用,但Java配置中没有示例.
以下链接提供了XML表示法: Spring Security中的多个身份验证提供程序
我们需要使用LDAP或DB进行身份验证
以下是我们的示例代码:
@Configuration
@EnableWebSecurity
public class XSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationProvider authenticationProvider;
@Autowired
private AuthenticationProvider authenticationProviderDB;
@Override
@Order(1)
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider);
}
@Order(2)
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProviderDB);
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/scripts/**","/styles/**","/images/**","/error/**");
}
______
@Override
@Order(1)
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/","/logout","/time").permitAll()
.antMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/index")
.loginProcessingUrl("/perform_login")
.usernameParameter("email")
.passwordParameter("password")
.failureUrl("/index?failed=true")
.defaultSuccessUrl("/summary",true)
.permitAll()
.and() …Run Code Online (Sandbox Code Playgroud) 我正在尝试自定义JQuery 1.8中自动完成元素的外观.我使用了JQuery UI网站上的示例
$('#term').autocomplete(
{source:'index.php?/Ajax/SearchUsers', minLength: 3, delay: 300}
).data("ui-autocomplete")._renderItem = function( ul, item ) {
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul );
};
Run Code Online (Sandbox Code Playgroud)
不幸的是,在JQuery UI 1.8中没有ui-autocomplete数据字段.我在哪里可以修改JQuery UI 1.8中自动完成的模板?
我们采用了Vincent Driessen提出的分支模型,我们几乎按照他在文章中描述的那样做了所有事情.
只有在处理发布分支时,我们才会略有偏差.
Vincent建议在开发人员分支的分支中开发特征.当决定哪些功能进入下一版本时,它们将合并回开发人员,并从中创建发布分支.
之后,功能分支应仅用于测试和错误修正.当发布部署为live时,发布分支将合并回开发人员和主服务器.
我们所做的是将功能直接合并到发布分支中:

我觉得这不是它应该做的方式,我试图想到这可能会使事情变得更复杂的情况.
我能想到的是以下几点:
假设一个新的Feature c正在建立在Feature a上,它已经被合并到一个发布分支中.我必须首先将发布分支合并回开发人员,以便能够从开发人员创建新的Feature c分支.
在其他情况下,这种分支模型会使事情变得更复杂吗?
我已经成功地使用Jersey创建了一个REST Web服务,并通过java安全注释来保护它.它看起来像这样
GET /users/ // gives me all users
GET /users/{id} // gives the user identified by {id}
POST /users/ // creates user
PUT /users/{id} // updates user identified by {id}
DELETE /users/{id} // delete user
Run Code Online (Sandbox Code Playgroud)
我还设置了一个具有两个角色的领域:用户和管理员
我保护所有方法,以便只有管理员才能访问它们.
现在我想免费提供PUT /users/{id}和GET /users/{id}方法,以便用户可以访问自己的, 只有自己的资源.
例:
// user anna is logged in and uses the following methods
GET /users/anna // returns 200 OK
GET /users/pete // returns 401 UNAUTHORIZED
Run Code Online (Sandbox Code Playgroud)
由于我找不到通过注释配置它的方法,我正在考虑将HTTP请求传递给相应的方法以检查是否允许用户访问资源.
对于该GET /users/{id}方法,它看起来像这样:
@GET
@Path("/users/{id}") …Run Code Online (Sandbox Code Playgroud) 假设我想构建一个REST服务来制作看起来像这样的注释:
GET /notes/ // gives me all notes
GET /notes/{id} // gives the note identified by {id}
DELETE /notes/{id} // delete note
PUT /notes/{id} // creates a new note if there is no note identified by {id}
// otherwise the existing note is updated
Run Code Online (Sandbox Code Playgroud)
由于我希望我的服务是无效的,我使用PUT来创建和更新我的笔记,这意味着客户设置/生成新笔记的ID.
我想过使用GUID/UUID,但它们很长,并且会让记住URL变得非常困难.同样从数据库的角度来看,当在大表中用作主键时,从性能的角度来看,这样的长字符串id可能很麻烦.
你知道一个很好的id生成策略,它可以产生短的ID,当然可以避免碰撞吗?
我正在尝试将Swagger集成到运行嵌入式灰熊服务器的Java SE应用程序中.
为了达到这个目的,我正在按照本教程进行操作,我很高兴我90%在那里.
我想使用这个servlet配置swagger:
@WebServlet(name = "SwaggerJaxrsConfig", loadOnStartup = 1)
public class SwaggerJaxrsConfig extends HttpServlet {
@Override
public void init(ServletConfig servletConfig) {
try {
super.init(servletConfig);
System.out.println("Swagger init");
SwaggerConfig swaggerConfig = new SwaggerConfig();
ConfigFactory.setConfig(swaggerConfig);
swaggerConfig.setBasePath("http://localhost:8082/swagger4javaee-web/rest");
swaggerConfig.setApiVersion("1.0.0");
ScannerFactory.setScanner(new DefaultJaxrsScanner());
ClassReaders.setReader(new DefaultJaxrsApiReader());
} catch (ServletException e) {
System.out.println(e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
由于我使用的是嵌入式服务器,因此@WebServlet注释不会将servlet添加到grizzly服务器.
有谁知道如何以编程方式将servlet添加到grizzly服务器?
PS我使用这种依赖
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-servlet</artifactId>
<version>2.9</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)