小编Rom*_*n C的帖子

Struts2是注释还是基于XML?哪个更容易管理和简单?

使用Struts2哪种更简单,更有条理的方式?使用注释还是使用XML文件?

如果有注释,那么使用哪种注释?使用struts-convention-plugin,您甚至可以避免完全编写约定,即@results或@action.

注释会有什么好处而不是写它们?

java xml annotations struts2 struts2-convention-plugin

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

如何将对象从前端传递给Struts2?

我试图通过JavaScript向Struts2后端发送一个字段的值,但它返回NullpointerException.

<input type="hidden" id="employee.payslip.id" name="employee.payslip.id" value="5"/>
....
Run Code Online (Sandbox Code Playgroud)

提交表单后,请求将被发送到以下JavaScript方法以发送到后端.

 function payslipPayment(){

     var formValues = $('#myform').serialize();
     ....
     xmlhttp.open("get","../payslip/pay?"+formValues,false);
     xmlhttp.send();

 }
Run Code Online (Sandbox Code Playgroud)

请求将被创建并发送如下

http://localhost/payslip/pay/employee.payslip.id=5&employee.payslip.year=2013&....
Run Code Online (Sandbox Code Playgroud)

但在后端,当我试图显示它返回的值NullPointerException.

Java的

public class payslip {

 private Employee employee;

 public String pay{
    System.out.println("Id:"+employee.payslip.id):
    System.out.println("Year:"+employee.payslip.year;
    ...
 }

 getter and setter 

}
Run Code Online (Sandbox Code Playgroud)

类

public class Employee {
   private Payslip payslip;
   ....
   getter and setter
}

public class Payslip{
  private long id;
  ...
  getter and setter
}
Run Code Online (Sandbox Code Playgroud)

javascript java ajax jquery struts2

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

Java初始化二维数组列表

我想做二维动态 ArrayList 示例:

[1][2][3]
[4][5][6]
[7][8][9]
Run Code Online (Sandbox Code Playgroud)

我使用了这个代码:

 ArrayList<ArrayList<Integer>> group = new ArrayList<ArrayList<Integer>>();
        group.add(new ArrayList<Integer>(1, 2, 3));
Run Code Online (Sandbox Code Playgroud)

我应该如何初始化这个数组列表?

java arraylist dynamic multidimensional-array

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

Hibernate inheritance, polymorphic saving

I have a class Person with two subclasses Student and Employee

@Entity(name="person")
@Inheritance(strategy = InheritanceType.JOINED)
public class Person implements Serializable {
    @Id
    @GeneratedValue
    private Integer id;
}

@Entity(name="student")
@PrimaryKeyJoinColumn(name="id")
public class Student extends Pessoa implements Serializable {
}

@Entity(name="employee")
@PrimaryKeyJoinColumn(name="id")
public class Employee extends Person implements Serializable {
}
Run Code Online (Sandbox Code Playgroud)

A student can also be an employee, but when I try to save a student with the same id as an employee, hibernate throws a duplicate primary key exception

org.hibernate.exception.ConstraintViolationException: Duplicate …
Run Code Online (Sandbox Code Playgroud)

java sql inheritance hibernate

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

如何在IntelliJ IDEA GUI设计器上为Java自由拖放元素?

每当我创建一个新的GUI表单时,我选择的所有基本布局管理器类型都有某种网格或对齐方式.如何制作它以便我可以在没有网格的情况下自由拖动按钮,文本框等?

我不会用Java知道,我只是在四处寻找,看看我是否可以将它作为一种额外的语言.

java user-interface intellij-idea

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

从Struts 1迁移到Struts 2

我计划使用Struts 1代码库迁移到Struts 2.我没有得到任何好的资源来继续这次迁移.你能帮忙解决这个问题吗?

java migration struts2 struts1

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

如何访问AngularJS保证链中先前承诺的结果?

我有以下代码:

authService.authenticate()
.then(function (user) {
  return Task.all({user: user})
})
.then(function (tasks) {
  // How to access user object here?
})
Run Code Online (Sandbox Code Playgroud)

是否有一些内置的方法将user对象传递给第二个then函数而不执行以下操作:

var user2 = null;
authService.authenticate()
.then(function (user) {
  user2 = user
  return Task.all({user: user})
})
.then(function (tasks) {
   // Use user2 here
})
Run Code Online (Sandbox Code Playgroud)

或这个:

authService.authenticate()
.then(function (user) {
  var defer = $q.defer()
  Task.all({user: user}).then(function (tasks) {
    return defer.resolve(user, tasks)
  })
  return defer.promise
})
.then(function (user, tasks) {
   // Use user2 here
})
Run Code Online (Sandbox Code Playgroud)

或通过then直接调用第二个来嵌套它们 …

javascript promise angularjs

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

如何按源顺序获取方法

我有一个自定义注释,我想在运行时使用它来显示对象属性。我希望它们以源代码顺序出现,但反射并不能保证Class.getMethods().

有没有办法通过反射或通过注释处理来按源顺序获取方法(如果涉及多个继承级别,至少每个类)?

举个例子,假设我有一个界面 Property

package test;

public @interface Property {
    public String name();
}
Run Code Online (Sandbox Code Playgroud)

和一个使用该注释的类

package test;

public class MyObject {
    @Property(name = "First")
    public void getFirst() {}

    @Property(name = "Another")
    public void getAnother() {}
}
Run Code Online (Sandbox Code Playgroud)

我想在属性“另一个”之前可靠地获得“第一个”属性。

我知道我可以在我的注释中添加一个排序属性并对其进行排序,但是如果需要的话,我有很多需要更新的类,所以我正在寻找一种通用方法来实现这一点,而无需修改单个注释。

java annotations annotation-processing

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

更新单个表的多行

我需要更新具有超过60k行的表的每一行.目前我这样做 -

public void updateRank(Map<Integer,Double> map){
        Iterator<Entry<Integer, Double>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Integer,Double> pairs = (Map.Entry<Integer,Double>)it.next();
            String query = "update profile set rank = "+ pairs.getValue()+ " where profileId = "+pairs.getKey();
            DBUtil.update(query);
            it.remove();
        }       
}
Run Code Online (Sandbox Code Playgroud)

仅此方法需要大约20分钟才能完成,每行(60k)命中数据库就是我认为的原因.(虽然我使用dbcp进行连接池,最多有50个活动连接)

如果我能够使用单个数据库命中更新行,那就太好了.那可能吗 ?怎么样 ?

或者其他任何改善时间的方法?

java mysql

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

inetOrgPerson与member或memberOf?

什么有效

假设我有inetOrgPersonS IN ou=people,dc=example,dc=com。例:

dn: cn=John Doe,ou=people,dc=example,dc=com
objectClass: inetOrgPerson (structural)
objectClass: person (structural)
objectClass: top (abstract)
cn: John Doe
sn: Doe
givenName: John
mail: john.doe@example.com
uid: john.doe
Run Code Online (Sandbox Code Playgroud)

另外我还有几个organization:

dn: o=foo,dc=example,dc=com
objectClass: organization (structural)
objectClass:top (abstract)
o: foo

dn: o=bar,dc=example,dc=com
objectClass: organization (structural)
objectClass:top (abstract)
o: bar
Run Code Online (Sandbox Code Playgroud)

每个organization都有一个groupOfNames:

dn: cn=users,o=foo,dc=example,dc=com
objectClass:groupOfNames (structural)
cn: users
member: cn=John Doe,ou=people,dc=example,dc=com

dn: cn=users,o=bar,dc=example,dc=com
objectClass:groupOfNames (structural)
cn: users
Run Code Online (Sandbox Code Playgroud)

如您所见,cn=John Doe,ou=people,dc=example,dc=com列为的member,cn=users,o=foo,dc=example,dc=com而不是的dn: …

ldap openldap

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