小编Don*_*mmy的帖子

为什么即使使用https,PHP的"SERVER_PROTOCOL"也会显示HTTP/1.1?

地址栏显示" https://mywebsite.com "并显示一个锁定图标(并单击显示它的AES-256),但是当我运行以下代码时,它始终打印"HTTP/1.1".

echo $_SERVER[ "SERVER_PROTOCOL" ];
Run Code Online (Sandbox Code Playgroud)

为什么不显示https?

php https

10
推荐指数
1
解决办法
2万
查看次数

在 SPring Boot 2.1.1 中扩展 GlobalMethodSecurityConfiguration 时出现错误,指出“methodSecurityInterceptor”已被定义

我正在覆盖GlobalMethodSecurityConfiguration该类,但只有一种方法:protected MethodSecurityExpressionHandler createExpressionHandler().

当我尝试运行该应用程序时,我得到:

描述:

无法注册在类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class] 中定义的 bean 'methodSecurityInterceptor'。具有该名称的 bean 已经在类路径资源 [com/testing/config/MyMethodSecurityConfig.class] 中定义并且覆盖被禁用。

行动:

考虑通过设置 spring.main.allow-bean-definition-overriding=true 重命名其中一个 bean 或启用覆盖

配置类

当我没有覆盖该基本方法时,为什么要这样做?如何在MethodSecurityExpressionHandler不出现此错误的情况下覆盖?

import com.testing.AadMethodSecurityExpressionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class MyMethodSecurityConfig extends GlobalMethodSecurityConfiguration
{
    @Override
    protected MethodSecurityExpressionHandler createExpressionHandler()
    {
        return new MyMethodSecurityExpressionHandler();
    }
}
Run Code Online (Sandbox Code Playgroud)

表达式处理程序

import org.aopalliance.intercept.MethodInvocation;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
import org.springframework.security.core.Authentication;

public class MyMethodSecurityExpressionHandler extends DefaultMethodSecurityExpressionHandler
{
    @Override
    protected MethodSecurityExpressionOperations createSecurityExpressionRoot(Authentication …
Run Code Online (Sandbox Code Playgroud)

java security spring spring-security spring-boot

9
推荐指数
1
解决办法
3215
查看次数

为什么IE8没有加载我的eot文件?

我下载了一些otf字体,然后将它们转换为eot使用:https://onlinefontconverter.com 但是当我在IE8中查看该网站时,字体不显示(它们显示在Chrome,Firefox,Opera,Android中).我的代码或eot都必须出错.有谁知道什么是错的?

(在此下载Roboto:http://www.fontsquirrel.com/fonts/roboto)

(在此处转换:https://onlinefontconverter.com)

styles.css的

@font-face
{
    font-family: RobotoCondensed;
    src: url("Roboto-Condensed.eot");
}

@font-face
{
    font-family: RobotoCondensed;
    src: url("Roboto-Condensed.ttf");
}

.myDiv
{
    font-family: RobotoCondensed, Arial, Helvetica;
    font-size: 10px;
    color: #e8e8e8;
}
Run Code Online (Sandbox Code Playgroud)

index.html(相关代码)

<div class="myDiv">Some font in here that shows incorrectly as Arial!</div>
Run Code Online (Sandbox Code Playgroud)

样式表和字体位于同一文件夹中.

html css fonts internet-explorer internet-explorer-8

8
推荐指数
1
解决办法
1万
查看次数

如何在Chrome上以高分辨率绘制画布?为什么如果devicePixelRatio === webkitBackingStorePixelRatio扩展到2倍提高分辨率?

我试图将300dpi图像绘制到画布对象,但在Chrome中它显示的质量非常差.当我使用下面的代码时,它没有改进,但那是因为devicePixelRatiobackingStoreRatio(两者都是1)相同.

然后我尝试强制进行一些比率更改并找到以下内容:

  • 如果我改变ratio2并强制缩放代码运行,那么它会以更好的分辨率绘制到画布.
  • 如果我改变ratio任何东西大于2(例如3,4,5,6,等等),那么它有可怜的分辨率!

这一切都是在台式计算机上完成的.

如何确保画布以高分辨率绘制?

(代码来自:http://www.html5rocks.com/en/tutorials/canvas/hidpi/)

/**
* Writes an image into a canvas taking into
* account the backing store pixel ratio and
* the device pixel ratio.
*
* @author Paul Lewis
* @param {Object} opts The params for drawing an image to the canvas
*/
function drawImage(opts) { …
Run Code Online (Sandbox Code Playgroud)

javascript html5 google-chrome canvas html5-canvas

8
推荐指数
2
解决办法
8975
查看次数

有没有办法在所有主流浏览器中检测纯文本缩放?

我做了一些研究,发现了很多帖子,包括这个,但它们都很旧,该页面上的答案链接到一个库,说它不再适用于Firefox或Chrome.

是否有当前可靠的方法来检测浏览器中的缩放和纯文本缩放?如何处理?

zoom browser-detection

8
推荐指数
1
解决办法
448
查看次数

如何在Spring Boot项目的debug/run上的IntelliJ"out"目录中生成build-info.properties?

在我的build.gradle中,我添加了spring build info:

springBoot {
    mainClass = "${springBootMainClass}"

    buildInfo() {
        additionalProperties = [
                name: "${appName}",
                version: "${version}-${buildNumber}",
                time: buildTime()
        ]
    }
}

def buildTime() {
    final dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")
    dateFormat.timeZone = TimeZone.getTimeZone('GMT')
    dateFormat.format(new Date())
}
Run Code Online (Sandbox Code Playgroud)

当我从命令行运行时,这会正确添加/META-INF/build-info.properties文件,/build/resources/main以便"/info"端点以JSON显示构建信息.

当我的IntelliJ的运行/调试按钮运行的IntelliJ并没有使用/build目录,而是使用/out目录,也没有运行gradle这个任务,所以/info端点具有空的JSON.

如何让它生成该文件并将其放在/out目录中?

java spring intellij-idea spring-boot spring-boot-actuator

8
推荐指数
3
解决办法
3068
查看次数

如何将非泛型List转换为List <String>?

当我尝试使用Java 8流进行转换时,出现编译错误:

不兼容的类型
必需:
找到的列表:java.lang.Object

    ArrayList list = new ArrayList();
    list.add("Test");
    list.add("Java");
    list.add("Other");

    //This won't compile
    List<String> strings = list.stream()
        .map(object -> Objects.toString(object, null))
        .collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)

java java-stream

8
推荐指数
1
解决办法
286
查看次数

如何在无状态微服务中使用 Spring Boot oAuth2 + Azure AD?

当我尝试使用Microsoft Azure的示例代码使用 oAuth2 和 Spring Boot 时,它使用有状态会话来检查身份验证/授权。你可以看到这一点:

  1. 它永远不会在任何调用中传递任何标头/JWT
  2. 它有一个 cookie“JSESSIONID”,您可以在新的邮递员会话中使用它(在不同的浏览器中获取它后),它会认为您已登录

这将不起作用,因为我们的微服务将是多个实例。

我如何将其转换为使用 JWT ( Authorization: Bearer AQab...) 而不是 cookie 进行后续调用?

依赖项:

//All using Spring Boot 2.0.5.RELEASE
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.security:spring-security-oauth2-client')
compile('org.springframework.security:spring-security-oauth2-jose')

//Using 2.0.7
compile('com.microsoft.azure:azure-active-directory-spring-boot-starter')
Run Code Online (Sandbox Code Playgroud)

配置:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserService;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;

@EnableWebSecurity
@EnableGlobalMethodSecurity( prePostEnabled = true )
public class OAuthConfig extends WebSecurityConfigurerAdapter
{
    @Autowired
    private OAuth2UserService<OidcUserRequest, OidcUser> userService;

    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http …
Run Code Online (Sandbox Code Playgroud)

spring spring-security azure spring-boot spring-security-oauth2

8
推荐指数
0
解决办法
3662
查看次数

在 C# 单元测试中,如何相当于 Java 的 Spy(而不是 Mock)来仅模拟类上的某些方法?

在 Java 中,当我有一个类调用其他类的静态方法时,我总是封装它,这样我就可以测试它,而无需实际访问该真实资源。例如:

public class HasSomeStaticCall
{
    public HasSomeStaticCall()
    {
        this.something = callStaticThing();
    }

    protected String callStaticThing()
    {
        return SomeThirdParty.getFromStaticMethod();
    {
}
Run Code Online (Sandbox Code Playgroud)

在Java 中,我可以使用Spy而不是Mock然后使用除该方法之外的所有实际方法。

例子:

public void test()
{
    HasSomeStaticCall obj = Mockito.spy( HasSomeStaticCall.class );

    //Only mock this one method
    Mockito.doReturn( "SomeValue" ).when( obj ).callStaticThing();
}
Run Code Online (Sandbox Code Playgroud)

我将如何在 C# 中执行此操作?(我使用的是.Net Framework 4.7.x,而不是.Net Core)

.net c# unit-testing mocking visual-studio

8
推荐指数
1
解决办法
7545
查看次数

如何覆盖React中的父类方法?

我正在扩展基类并覆盖基类中的方法.但是当我调用它时,它会调用超类版本.如何覆盖该方法?

    var Hello = React.createClass( {

        getName: function() { return "super" },

        render: function() {

            return <div>This is: {this.getName()}</div>;
        }
    });

    class HelloChild extends Hello {
        constructor(props) {
          super(props);

          console.log( this.getName());
        }
        getName()
        {
          return "Child";
        }
    };
Run Code Online (Sandbox Code Playgroud)

我希望它打印"这是:孩子",但它打印"这是:超级"

javascript ecmascript-6 reactjs react-jsx

7
推荐指数
2
解决办法
7026
查看次数