小编Ora*_*tus的帖子

如何使用javascript从我的服务器获取数据到我的JSP?

我正在使用javascript和JSP开发一个地图创建Web应用程序.在某些时候,我希望我的用户能够将他们创建的地图保存到我的数据库中,但是我必须检查地图的名称是否已经存在.我需要这样做而不离开页面本身,否则我将失去存储在该JSP中的地图.

所以问题是:如何在不更改页面/网址的情况下从我的服务器获得响应?

javascript java jsp

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

为什么不Reflection.getFieldsAnnotatedWith()返回任何字段?

我遇到了一个问题的思考.我正在尝试Set使用Reflections#getFieldsAnnotatedWith方法得到一个字段,但是当我运行单元测试时,它什么也没有返回,有人可以告诉我为什么吗?(我正在使用IntelliJ IDE)

这是我正在使用的课程,这是非常基础的.

//The test class run with junit

public class ReflectionTestingTest {

    @Test
    public void test() {
        Reflections ref = new Reflections(AnnotatedClass.class);
        assertEquals(2, ref.getFieldsAnnotatedWith(TestAnnotation.class).size());
        Set<Field> fields = ref.getFieldsAnnotatedWith(TestAnnotation.class);
    }
}

//The class with the annotated fields I want to have in my Set.

public class AnnotatedClass {

    @TestAnnotation
    public int annotatedField1 = 123;

    @TestAnnotation
    public String annotatedField2 = "roar";
}

//And the @interface itself

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TestAnnotation {}
Run Code Online (Sandbox Code Playgroud)

测试失败,并显示以下消息: …

java reflection unit-testing annotations reflections

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