小编Ich*_*aki的帖子

无法在MySQL中创建FOREIGN KEY CONSTRAINT

我在Ubuntu中使用phpMyAdmin 3.5.8.1deb1创建了我的MySQL数据库.

而不是我的所有表都是InnoDB,我不能添加外键,这是一个例子:

ALTER TABLE element ADD CONSTRAINT FK_element_id_user FOREIGN KEY (id_user) REFERENCES user(id) ON DELETE SET NULL ON UPDATE CASCADE;
Run Code Online (Sandbox Code Playgroud)

当我运行此脚本时,我收到此错误:

#1005 - 无法创建表'tpw.#sql-4d8_e2'(错误号:150)(详情......)

当我点击细节时,我得到了这个:

InnoDB文档支持事务,行级锁定和外键

我试图在关系视图中手动添加FK

mysql foreign-keys phpmyadmin

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

Java Swing:在NetBeans中按代码添加组件

我正在使用NetBeans,而且我使用NetBeans的调色板JFrame添加了一个JPanelNetBeans.

我想JRadioButton手动添加一个JPanel,所以这是我在构造函数中尝试的代码:

ButtonGroup group = new ButtonGroup();
JRadioButton btn1 = new JRadioButton("btn1 ");
JPanel1.add(btn1);
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,JFrame我没有看到JRadioButton任何地方,但是当我使用NetBens's调色板添加它时它会起作用.

我怎么解决这个问题 ?

java swing netbeans jpanel jradiobutton

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

防止链接重定向到另一个页面

我的页面中有一个链接,我想阻止此链接将我重定向到 href 属性中的链接。

我尝试如下:

$(function(){
    $('#logout-link').click(function(event){
        event.preventDefault();

        $.ajax({
            url     : $(this).attr('href'),
            success : function(data){
                $('#login-loader').hide();
                        location.reload(true);
            },
            error   : function(){
                $('#error-login').replaceWith('<div id="error-login" class="msg fail"><p>Une erreur a été rencontrée lors du deconnexion!</p></div>');
            }
        });


    });
});
Run Code Online (Sandbox Code Playgroud)

但它仍然将我重定向到另一个页面。

如何防止链接重定向到另一个页面?

javascript jquery

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

将log4j.properties文件放在spring启动应用程序中的位置

我已经创建了一个log4j.properties文件,并将其作为application.properties文件放在resources文件夹中,在这个文件中我有这一行:logging.config=log4j.properties它表示我的log4j属性文件的名称,但是当我运行我的应用程序时,我收到此错误我的控制台:

Logging system failed to initialize using configuration from 'log4j.properties'
java.io.FileNotFoundException: C:\Users\***\Desktop\CapRecrute\log4j.properties (The system cannot find the file specified)
Run Code Online (Sandbox Code Playgroud)

所以我试图将logging.config属性更改为src\\main\\resources\\log4j.properties,然后我又得到了一个错误:

java.lang.IllegalStateException: Could not initialize Logback logging from src\main\resources\log4j.properties ... Caused by: ch.qos.logback.core.LogbackException: Unexpected filename extension of file [file:/C:/Users/Aimad%20MAJDOU/Desktop/CapRecrute/src/main/resources/log4j.properties]. Should be either .groovy or .xml
Run Code Online (Sandbox Code Playgroud)

在我的pom文件中我有这个:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

log4j spring-boot

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

在 IE 和页脚顶部制作一个 div 粘性

我想让一个 div 粘在滚动上,但是当它总是停留在页脚的顶部时。

我尝试使用position:stickywhich 工作正常,但它在 IE11 上不起作用。

我也为类似的问题尝试了多种解决方案,但他们总是提到如何使页脚具有粘性,而不是<div>在 main <div>.

这是我的代码的样子:

.slider {
  background: #006264;
  color: white;
  position: sticky;
  bottom: 0px;
  width: 100%;
  height: 60px;
}

.footer {
  background: #04246A;
  color: white;
  font-weight: bold;
  margin: 0 auto;
  height: 119px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="main">
  <div class="placeholder">This div holds place</div>
  <div class="placeholder">This div holds place</div>
  <div class="placeholder">This div holds place</div>
  <div class="placeholder">This div holds place</div>
  <div class="placeholder">This div holds place</div>
  <div class="slider">
    This is the footer
  </div>
</div> …
Run Code Online (Sandbox Code Playgroud)

html css sticky internet-explorer-11

5
推荐指数
0
解决办法
467
查看次数

如何在javascript中通过ref引用传递变量

我有一个范围变量,false默认情况下有值.

当我将此变量传递给函数以将其值修改为时,我想要true.

但这是不可能的,因为JavaScript中params的传递是有价值的.

这是我尝试做的简单代码:

myapp.controller('PersonCtrl', function ($scope) { 
    $scope.step = false;
    change($scope.step);
    console.log($scope.step);
});

change = function(step){
  step = true;
}
Run Code Online (Sandbox Code Playgroud)

的jsfiddle:

http://jsfiddle.net/SNF9x/177/

我该怎么解决这个问题?

javascript

4
推荐指数
1
解决办法
58
查看次数

通知控制器指令中的更改

我有一个指令如下:

(function () {
    'use strict';

    angular.module('components.tree-component').directive('myTree', myTreeDirective);

    myTreeDirective.$inject = ['$http', '$compile', 'loggerFactory', '$q'];

    function myTreeDirective($http, $compile, loggerFactory, $q) {

        
        function addActionButtons(scope, element, attrs, tree) {
            var actionButtons = '<span class="action-button-container">' +
                '<md-button class="md-icon-button" aria-label="Nouveau" ng-click="createNode($event)">' +
                '<md-icon class="material-icons">add_circle</md-icon>' +
                '</md-button>' +
                '<md-button class="md-icon-button" aria-label="Modifier" ng-click="renameNode($event)">' +
                '<md-icon class="material-icons">edit</md-icon>' +
                '</md-button>' +
                '<md-button class="md-icon-button" aria-label="Supprimer" ng-click="removeNode($event)">' +
                '<md-icon class="material-icons">delete_circle</md-icon>' +
                '</md-button>' +
                '</span>';
            // foreach node that has actions set to true append action buttons to it's DOM
            for (var …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

4
推荐指数
1
解决办法
622
查看次数

更改 contentEditable div 的字体大小

我有一个contentEditable div

\n\n
<div id="editor" contentEditable="true"> Enter your text here.. </div>\n
Run Code Online (Sandbox Code Playgroud)\n\n

还有一个dropdown button

\n\n
<div class="btn-group">\n    <button class="btn dropdown-toggle" data-toggle="dropdown" title="Taille de police"><i class="fa fa-text-height"></i>&nbsp;<b class="caret"></b></button>\n    <ul class="dropdown-menu" id="tailles"></ul>\n</div>\n
Run Code Online (Sandbox Code Playgroud)\n\n

为了用项目填充此下拉列表,我正在使用此脚本:

\n\n
//Liste des tailles utilis\xc3\xa9\nvar tailles = [\n    \'Petite (8px)\',\n    \'Petite (10px)\',\n    \'Petite (12px)\',\n    \'Normale (14px)\',\n    \'Grande (18px)\',\n    \'Grande (24px)\',\n    \'Grande (36px)\'\n];\n\n    //R\xc3\xa9cuperer le drop down du Taille de police\n    var taillesDropDown = document.getElementById(\'tailles\');\n\n    //Population du drop down Taille du police\n    tailles.forEach(function(taille){\n        var li …
Run Code Online (Sandbox Code Playgroud)

html javascript css contenteditable

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

java.lang.NoClassDefFoundError:org/hibernate/cfg/AnnotationConfiguration

我已经创建了一个Web动态项目,并希望Hibernate与它一起使用.

然后,我用它Hibernate Code Generation来生成类代码,然后我创建了一个HibernateUtil初始化的类SessionFactory.

public class HibernateUtil {
    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory(){
        try{
            SessionFactory sessionFactory = 
                    new AnnotationConfiguration().configure().buildSessionFactory();
            return sessionFactory;
        }catch(Exception ex){
            ex.printStackTrace();
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public static void shutdown() {
        getSessionFactory().close();
    }
}
Run Code Online (Sandbox Code Playgroud)

而另一课HibernateSessionFactoryListener:

public class HibernateSessionFactoryListener implements ServletContextListener{

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        System.out.println("\n Context Initilaise …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

处理返回 Promise 或 null 值的函数

我定义了一个函数如下:

function getCurrentComponent(){
    if($rootRouter._currentInstruction){
        return $rootRouter.recognize($rootRouter._currentInstruction.urlPath).then(function (data) {
            return data.component.componentType;
        });
    }else{
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

为了调用这个函数,我做了如下操作:

factory.getCurrentComponent().then(function (data) {
    ...
});
Run Code Online (Sandbox Code Playgroud)

问题是当getCurrentComponent函数返回空值时,会生成以下错误:

无法读取 null 的属性“then”

我该如何解决这个问题?

编辑:

我忘了说我仅限于使用 ES5,所以我无法使用该对象Promise

javascript ecmascript-5 angularjs angular-promise

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