小编Ahm*_*our的帖子

如何使用HtmlUnit处理太多的重定向

我试图解析一个网站,但我遇到了一个Too much redirect例外.这是我的代码:

WebClient client = new WebClient(BrowserVersion.FIREFOX_24);
HtmlPage homePage = null;
String url = "http://www.freelake.org/pages/Freetown-Lakeville_RSD/Departments/Director_of_Financial_Operatio";
try {
    client.getOptions().setUseInsecureSSL(true);
    client.setAjaxController(new NicelyResynchronizingAjaxController());
    client.getOptions().setThrowExceptionOnFailingStatusCode(false);
    client.getOptions().setThrowExceptionOnScriptError(false);
    client.waitForBackgroundJavaScript(30000);
    client.waitForBackgroundJavaScriptStartingBefore(30000);
    client.getOptions().setCssEnabled(false);
    client.getOptions().setJavaScriptEnabled(true);
    client.getOptions().setRedirectEnabled(true);
    homePage = client.getPage(url);
    synchronized (homePage) {
        homePage.wait(25000);
    }
    System.out.println(homePage.asXml());
} catch (Exception e) {
    e.printStackTrace();
}        
Run Code Online (Sandbox Code Playgroud)

以下提到例外情况

com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: Too much redirect for http://www.freelake.org/resolver/2345183424.20480.0000/route.00/pages/Freetown-Lakeville_RSD/Departments/Director_of_Financial_Operatio
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1353)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1371)
Run Code Online (Sandbox Code Playgroud)

有什么方法可以解决这个问题吗?

java htmlunit

3
推荐指数
1
解决办法
3964
查看次数

如何在 Teradata 中将纪元时间转换为人类可读的时间

在我的 Teradata 表中,该列下有纪元时间戳dhTimestamp

dhTimestamp  
1435308067705  
1434965874565  
1434763800794  
1434775876034  
1434765207057  
Run Code Online (Sandbox Code Playgroud)

如何在 Teradata 上将纪元时间戳转换为人类日期/时间格式?

epoch teradata

3
推荐指数
1
解决办法
6940
查看次数

"选择不能在任何服务器上运行"

我一直在Eclipse中开展动态Web项目.我收到了这个错误.

"选择不能在任何服务器上运行".

早些时候它工作正常但现在我收到了这个错误.我删除了服务器并再次添加.

Project- > Right Click- > Properties- > Server这里没有显示服务器,还有两个选项:Restore Default和Apply.我无法在这里添加服务器.

请告诉我想要的是这个问题.

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>try</groupId>
<artifactId>try</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>try Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
    <spring.version>3.2.0.RELEASE</spring.version>
</properties>

<!-- Dependencies -->
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.7</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.0.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <type>maven-plugin</type>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.0.Final</version>
    </dependency> …
Run Code Online (Sandbox Code Playgroud)

java

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

如何使用spring security(spring boot)实现Ldap身份验证

我有以下代码与我我试图实现ldap身份验证,但我认为它没有发生.

我的安全配置

@EnableWebSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class Config extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.httpBasic().and().authorizeRequests().antMatchers("/*")
                .permitAll().anyRequest().authenticated().and().csrf()
                .disable().httpBasic().and().csrf()
                .csrfTokenRepository(csrfTokenRepository()).and()
                .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);

    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth)
            throws Exception {
        auth.ldapAuthentication()
                .userSearchFilter("(uid={0})")
                .userSearchBase("dc=intern,dc=xyz,dc=com")
                .contextSource()
                .url("ldap://192.168.11.11:1234/dc=intern,dc=xyz,dc=com")
                .managerDn("username")
                .managerPassword("password!")
                .and()
                .groupSearchFilter("(&(objectClass=user)(sAMAccountName=" + "username" + "))");

    }

    private Filter csrfHeaderFilter() {
        return new OncePerRequestFilter() {
            @Override
            protected void doFilterInternal(HttpServletRequest request,
                    HttpServletResponse response, FilterChain filterChain)
                    throws ServletException, IOException {
                CsrfToken csrf = (CsrfToken) request
                        .getAttribute(CsrfToken.class.getName());
                if (csrf != null) { …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-security spring-boot

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

htop ubuntu狡猾的百分比数字丢失

我刚升级到Ubuntu 15.10(狡猾).

我注意到htop不再显示CPU,内存和交换的百分比数字.

这是一个错误还是"新的"方式?

ubuntu htop

3
推荐指数
1
解决办法
809
查看次数

java openCV Core.inRange 输入参数

Core.inRange(frame, new Scalar(minA,minB,minC), new Scalar(maxA,maxB,maxC), dst);
Run Code Online (Sandbox Code Playgroud)

我不明白应该向标量输入哪个参数。以及如何将 RGB 转换为它。(我使用的是 openCV 2.412)。根据http://docs.opencv.org/2.4.12/doc/tutorials/core/basic_geometric_drawing/basic_geometric_drawing.html?highlight=scalar 参数应该是 BGR,但它没有达到预期的结果。

输入:

Core.inRange(frame, new Scalar(0,0,0), new Scalar(0,0,255), dst);
Run Code Online (Sandbox Code Playgroud)

输入图片: 在此处输入图片说明

输出:

在此处输入图片说明

java opencv

3
推荐指数
1
解决办法
6236
查看次数

如何在 Unity 3D 中使用称重秤?

目前我正在使用 C# 统一创建一个 2d 平台游戏,我想知道如何创建一个像下面这样的秤。 在此处输入图片说明

为了解释一下,我想要这样,当一个重物rigidbody2d放在一个秤上时,另一个秤会向上移动,反之亦然。如果重量相等,我也希望它可以使秤平衡。我将如何接近这个?是否有一个组件可以轻松实现这一目标?

c# unity-game-engine game-physics unity3d-2dtools

3
推荐指数
1
解决办法
1576
查看次数

使用Mockito模拟java.lang.reflect.Method

我需要模拟java.lang.reflect.Method进行测试(我有动态的东西)。我们已经使用Junit spring&mockito编写了所有测试用例。但是我在为我的方面编写Junit时遇到问题。此外,我们还编写了自定义注释,请对此提供帮助

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/services-test.xml")
@ImportAutoConfiguration(RefreshAutoConfiguration.class)
public abstract class AbsServicesTest extends AbstractJUnit4SpringContextTests {

static{
    System.setProperty("LOCAL");
}
}


public class TaxValidatorAspectTest extends AbsServicesTest {

@Autowired
private ResourcesUtils resourcesUtil;

@Mock
private JoinPoint joinPoint;

@Mock
private MethodSignature methodSignature;

@Mock
private Method method;

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(new TaxValidatorAspectTest());
    Mockito.when(joinPoint.getSignature()).thenReturn(methodSignature);
    Mockito.when(methodSignature.getMethod()).thenReturn(method);
}

@Test
public void testBeforeMethod() throws IOException{
    TaxValidatorAspect taxonomyValidationAspect = new TaxValidatorAspect();
    final Object[] arguments = new Object[4];
    arguments[0] = requiredParam1;
    arguments[1] = requiredParam2;
    arguments[2] = requiredParam3;
    Mockito.when(joinPoint.getArgs()).thenReturn(arguments);
    taxonomyValidationAspect.before(joinPoint);
}
} …
Run Code Online (Sandbox Code Playgroud)

final class mockito

3
推荐指数
1
解决办法
1383
查看次数

HttpClient vs HtmlUnit

我知道HtmlUnit模拟浏览器,而HttpClient不是.

HtmlUnit,当一个页面加载并且里面有一个JavaScript时,脚本会被执行吗?如果脚本设置了cookie,cookie是否会在HtmlUnit浏览器中设置并可从Java代码访问?

有没有什么可以使用HttpClient,但不能使用HtmlUnit?在HtmlUnit,我们可以从POST请求开始并修改HTTP请求的任何部分,包括方法,URI,HTTP版本,标题和正文吗?

有什么优势HttpClientHtmlUnit

java httpclient htmlunit

3
推荐指数
1
解决办法
568
查看次数

VSTS:我可以从 Release 定义访问 Build 变量吗?

在 VSTS CI/CD 中,我在 CI 的 Powershell 任务中设置了一些变量的值。在 CD 期间,我想访问该变量的值来做某事,比如说 echo。

这可能吗?如果是这样,如何?

azure-devops azure-pipelines azure-pipelines-release-pipeline

3
推荐指数
2
解决办法
5435
查看次数