草庐IT

休息室

全部标签

java - 休息 - 如何获取调用者的 IP 地址

我正在编写JavaRestWeb服务,需要调用者的IP地址。我以为我曾经在cookie中看到过这个,但现在我看不到了。是否有一致的地方可以获取这些信息?我看到了一个使用“OperationalContext”来获取它的示例,但那不是在java中。 最佳答案 注入(inject)HttpServletRequest像这样进入您的休息服务:importjavax.servlet.http.HttpServletRequest;@GET@Path("/yourservice")@Produces("text/xml")publicStri

java - 休息 - 如何获取调用者的 IP 地址

我正在编写JavaRestWeb服务,需要调用者的IP地址。我以为我曾经在cookie中看到过这个,但现在我看不到了。是否有一致的地方可以获取这些信息?我看到了一个使用“OperationalContext”来获取它的示例,但那不是在java中。 最佳答案 注入(inject)HttpServletRequest像这样进入您的休息服务:importjavax.servlet.http.HttpServletRequest;@GET@Path("/yourservice")@Produces("text/xml")publicStri

java - Spring Security 在休息服务中获取用户信息,用于经过身份验证和未经过身份验证的用户

我有一个springrest服务,我想将它用于经过身份验证和未经过身份验证的用户。如果用户通过身份验证,我想从SecurityContextHolder.getContext().getAuthentication()获取用户信息。如果我使用.antMatchers("/app/rest/question/useroperation/list/**").permitAll()在ouath2配置中,如下所示,然后我可以获得用户信息经过身份验证的用户,但未经过身份验证的用户出现401错误。如果我.antMatchers("/app/rest/question/useroperation/l

java - Spring Security 在休息服务中获取用户信息,用于经过身份验证和未经过身份验证的用户

我有一个springrest服务,我想将它用于经过身份验证和未经过身份验证的用户。如果用户通过身份验证,我想从SecurityContextHolder.getContext().getAuthentication()获取用户信息。如果我使用.antMatchers("/app/rest/question/useroperation/list/**").permitAll()在ouath2配置中,如下所示,然后我可以获得用户信息经过身份验证的用户,但未经过身份验证的用户出现401错误。如果我.antMatchers("/app/rest/question/useroperation/l

spring - 通过没有表单登录的 Spring Security 休息基本身份验证

我正在尝试创建一个可供其他Web服务使用的RestfulWeb服务。理想情况下,当客户端访问服务并且未经过身份验证时,他们应该得到401。我希望用户能够通过向请求添加身份验证header来进行身份验证。我不希望用户填写登录表单并发布。我也不希望它在cookie中存储任何登录凭据(即保持状态),它应该都在随每个请求发送的authheader中。我已经使用springroo创建了web服务。我目前所拥有的(取自springsecurity3.1教程之一),当用户收到401时,会提示他们登录页面,然后发布页面,获取他们随每个请求发送的cookie.这是我的SpringSecurityxml。

spring - 通过没有表单登录的 Spring Security 休息基本身份验证

我正在尝试创建一个可供其他Web服务使用的RestfulWeb服务。理想情况下,当客户端访问服务并且未经过身份验证时,他们应该得到401。我希望用户能够通过向请求添加身份验证header来进行身份验证。我不希望用户填写登录表单并发布。我也不希望它在cookie中存储任何登录凭据(即保持状态),它应该都在随每个请求发送的authheader中。我已经使用springroo创建了web服务。我目前所拥有的(取自springsecurity3.1教程之一),当用户收到401时,会提示他们登录页面,然后发布页面,获取他们随每个请求发送的cookie.这是我的SpringSecurityxml。

spring - 如何在 Spring Boot 休息服务方法中设置响应 header value ?

新手问题...我正在构建我的第一个SpringBootRestful服务。我的Restful服务设计需要在响应header中返回一些数据。如何在我的Controller类方法中设置响应header值? 最佳答案 来自Spring文档:@RequestMapping("/handle")publicResponseEntityhandle(){URIlocation=...;HttpHeadersresponseHeaders=newHttpHeaders();responseHeaders.setLocation(location)

spring - 如何在 Spring Boot 休息服务方法中设置响应 header value ?

新手问题...我正在构建我的第一个SpringBootRestful服务。我的Restful服务设计需要在响应header中返回一些数据。如何在我的Controller类方法中设置响应header值? 最佳答案 来自Spring文档:@RequestMapping("/handle")publicResponseEntityhandle(){URIlocation=...;HttpHeadersresponseHeaders=newHttpHeaders();responseHeaders.setLocation(location)

spring - 使用 Spring 数据休息发布嵌套对象?

我最近开始在我的应用程序中使用spring-data-rest。我有以下JPA实体:@EntitypublicclassSuper{@Idprivatelongid;@JoinTable@OneToMany(cascade=CascadeType.ALL)privateListchildren;}-----------------------------------------@EntitypublicclassSuper2{@Idprivatelongid;@JoinTable@OneToMany(cascade=CascadeType.ALL)privateListchildren

spring - 使用 Spring 数据休息发布嵌套对象?

我最近开始在我的应用程序中使用spring-data-rest。我有以下JPA实体:@EntitypublicclassSuper{@Idprivatelongid;@JoinTable@OneToMany(cascade=CascadeType.ALL)privateListchildren;}-----------------------------------------@EntitypublicclassSuper2{@Idprivatelongid;@JoinTable@OneToMany(cascade=CascadeType.ALL)privateListchildren