小编edw*_*yte的帖子

502哎呀,GitLab花了太多时间来回应

我在Raspberry Pi2上安装了Gitlab,它运行了几个月.但是由于关闭了RPi的功能,它不再起作用了.网页返回502错误.

502哎呀,GitLab花了太多时间来回应.

所以我尝试了reconfigure(sudo gitlab-ctl reconfigure)但是,它失败并显示错误消息:

FATAL: Errono::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题.

gitlab

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

如何对弹簧安全性进行单元测试@PreAuthorize(hasRole)?

为了在控制器方法上对PreAuthorize注释的hasRole部分进行单元测试,我需要什么?

我的测试应该成功,因为登录用户只有两个角色中的一个,但它失败并出现以下断言错误:

java.lang.AssertionError:状态

预计:401

实际:200

我在MyController中有以下方法:

@PreAuthorize(value = "hasRole('MY_ROLE') and hasRole('MY_SECOND_ROLE')")
@RequestMapping(value = "/myurl", method = RequestMethod.GET)
public String loadPage(Model model, Authentication authentication, HttpSession session) {
    ...stuff to do...
}
Run Code Online (Sandbox Code Playgroud)

我创建了以下abstract-security-test.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:security="http://www.springframework.org/schema/security"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd">

    <security:global-method-security secured-annotations="enabled" />

    <security:authentication-manager alias="authManager">
        <security:authentication-provider>
            <security:user-service>
                <security:user name="missingsecondrole" password="user" authorities="MY_ROLE" />
            </security:user-service>
        </security:authentication-provider>
    </security:authentication-manager>

</beans>
Run Code Online (Sandbox Code Playgroud)

在我的单元测试中我有这个:

@ContextConfiguration("classpath:/spring/abstract-security-test.xml")
public class MyTest {
    private final MyController myController = new MyController();
    @Autowired
    private AuthenticationManager manager;

    @Test
    public void testValidUserWithInvalidRoleFails() throws …
Run Code Online (Sandbox Code Playgroud)

java testing mocking spring-security

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

撤消git提交

您是否可以通过git命令撤消过去的提交,该提交早已合并到您的git存储库中?或者您是否必须手动撤消该提交中所做的所有更改?

git git-commit

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

除非选中复选框,否则Jquery停止表单提交

我有这个代码,但它似乎没有返回true.警报始终显示.任何想法(无需创建一个var来存储已选中的复选框,因为它看起来有点像hacky).

谢谢.

$("#form").submit(function(e) {
    $('input[type=checkbox]').each(function () {
        if(this.checked){
            return true;
        }
    });
    alert("Please select at least one to upgrade.");
    return false;
});
Run Code Online (Sandbox Code Playgroud)

forms checkbox jquery submit

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

合并两个没有重复的列表

我想将列表中的项目添加到另一个列表而不重复.我使用了下面涉及一组的方法.这是实现最终结果的最有效方式吗?是否有更简洁的方法来更新lista以包含唯一的setboth对象?

Set setboth = new HashSet(lista);
setboth.addAll(listb);
lista.clear();
lista.addAll(setboth);
Run Code Online (Sandbox Code Playgroud)

java list set

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

Graphite:总结与模式匹配的所有统计数据?

我正在通过发送统计信息到Graphite服务器statsd.我的统计数据相当精细,开发人员可以轻松添加.我想汇总匹配某种模式的所有统计数据(stats.timers.api.*.200.count例如).Graphite中有可能吗?

如果没有,是否有其他我应该关注的系统可以从中生成这种类型的汇总数据statsd?或者这是我应该在我的statsd配置中直接做的事情?

graphite statsd

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

朱莉娅的(x:y)运营商

我想了解这段代码:

  r = (1:10) - (4/1)
    println(r)
Run Code Online (Sandbox Code Playgroud)

输出:

-3.0:1.0:6.0

我明白了为什么我得到了-3和6.但为什么我在中间得到这个值(1.0)?朱莉娅如何计算它?或者我如何谷歌呢?

julia ijulia-notebook

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

阻止CMD始终以管理员权限打开

无论我如何打开它,cmd.exe始终以管理员权限打开.我怎么能不打开它?是否缺少一些注册表设置?即使我直接从运行对话框打开它,或者双击system32文件夹,它仍然会打开admin privs.

谢谢.

cmd admin windows-7

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

没有jquery或iframes的AJAX文件上传/表单提交?

是否有可能在没有jQuery或IFrame的情况下提交AJAX表单(所以只是纯JavaScript)?我正在发送一个有效的struts fileUploadAction.动作的代码是否仍然适用于异步提交,或者是否需要添加异步表单提交?

我正在使用struts 1.x,目前我的表单是:

<html:form action="fileUploadAction" method="post" enctype="multipart/form-data">
    ...form elements...
    <html:file property="theFile" />
    ...other elements...
</html:form>
Run Code Online (Sandbox Code Playgroud)

是否可以提交此表单,从而使用AJAX上传文件?

javascript ajax struts asyncfileupload

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

在Spring MVC上使用Servlet 3.0的MultipartConfig

如何将多部分配置添加到spring mvc应用程序中,该应用程序使用带有使用RequestMapping注释的方法的控制器?

背景:

我想启用csrf保护,所以在我的spring配置中添加了security:csrf标签.我有一个控制器类,其中一个方法使用RequestMapping进行注释,用于上传文件.我还遵循了多部分的警告说明,我在安全过滤器上方添加了多部分过滤器.当我在添加csrf标签后尝试上传文件时,我遇到了一个缺少getParts()方法的异常.一个快速谷歌强调这是由于使用基于servlet 2.5规范的jetty版本.我将jetty-maven-plugin升级到8.1.14.v20131031并再次尝试上传.导致:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: No multipart config for servlet
        at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:68)
        at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:58)
        at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:110)
Run Code Online (Sandbox Code Playgroud)

我在哪里为xml设置放置多部分配置?所有文档都说要在web.xml中的特定servlet的servlet标记中添加multipart-config.但是我的应用程序只有一个servlet.所以我添加了它,但我仍然遇到同样的问题.

<servlet>
    <servlet-name>SpringDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <multipart-config>
        <location>/tmp</location>
        <max-file-size>20848820</max-file-size>
        <max-request-size>418018841</max-request-size>
        <file-size-threshold>1048576</file-size-threshold>
    </multipart-config>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/servlet-context.xml
        </param-value>
    </init-param>
    <load-on-startup>10</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)

我还更新了web.xml顶部的模式位置,指向servlet规范的3.0版本,源自http://www.mkyong.com/web-development/the-web-xml-deployment-descriptor-examples /.

有帮助吗?

编辑:为Rob添加了以下riles:

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/spring/webapp.xml</param-value>
    </context-param>

    <context-param>
        <param-name>spring.profiles.default</param-name>
        <param-value>OracleDB,common</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher
        </listener-class>
    </listener>

    <servlet> …
Run Code Online (Sandbox Code Playgroud)

spring-mvc multipart csrf spring-security servlet-3.0

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