小编use*_*806的帖子

如何从ProceedingJoinPoint获取方法的注释值?

我有下面的注释.

MyAnnotation.java

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {

}
Run Code Online (Sandbox Code Playgroud)

SomeAspect.java

public class SomeAspect{

 @Around("execution(public * *(..)) && @annotation(com.mycompany.MyAnnotation)")
    public Object procede(ProceedingJoinPoint call) throws Throwable {

  //Some logic

}

}
Run Code Online (Sandbox Code Playgroud)

SomeOther.java

public class SomeOther{

@MyAnnotation("ABC") 
public String someMethod(String name){


}


}
Run Code Online (Sandbox Code Playgroud)

在上面的类中我在@MyAnnotation中传递" ABC " .现在我如何在SomeAspect.java类的procede方法中访问" ABC "值?

谢谢!

java spring spring-aop spring-3 java-ee-7

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

在java中扩展Exception/RunTimeException?

我有以下课程.

public class ValidationException extends RuntimeException {


}
Run Code Online (Sandbox Code Playgroud)

public class ValidationException extends Exception {


}
Run Code Online (Sandbox Code Playgroud)

我很困惑自定义异常何时应该扩展RunTimeException以及什么时候必须扩展Exception.能否请您解释一下我是否有RunTimeException直接延伸的缺点?

谢谢!

java exception

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

使用批处理文件执行一组SQL查询?

我正在使用SQL Server数据库.我有这些SQL查询:

Delete from TableA;
Delete from TableB;
Delete from TableC;
Delete from TableD;
Delete from TableE;
Run Code Online (Sandbox Code Playgroud)

是否可以使用批处理文件运行这些脚本?该数据库是一个远程数据库.

谢谢!

database sql-server cmd batch-file

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

在Label的悬停上显示工具提示?

我有以下HTML代码?

<label for="male">Hello This Will Have Some Value</label>
Run Code Online (Sandbox Code Playgroud)

但实际上我没有足够的空间来展示这么长的标签.所以我想创建如下标签..

<label for="male">Hello...</label>
Run Code Online (Sandbox Code Playgroud)

然后我创建一个隐藏字段,它将保存整个标签值

<input type="hidden" name="Language" value="Hello This Will Have Some Value">
Run Code Online (Sandbox Code Playgroud)

现在,当用户将鼠标悬停在上面Hello...时,我可以Hello This Will Have Some Value使用jquery在工具提示中显示隐藏字段的值吗?

谢谢!

html javascript css jquery html5

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

如何在javascript文件中访问Spring MVC模型对象?

我正在使用spring 3 MVC,我有以下课程.

外部系统将使用以下URL调用我的应用程序:

http://somehost/root/param1/param2/param3
Run Code Online (Sandbox Code Playgroud)

我有一个spring MVC控制器方法如下:

public ModelAndView showPage(@PathVariable("param1") String paramOne, @PathVariable("param2") String paramTwo, @PathVariable("param3") String paramThree, HttpServletResponse response) {  
        SomeModel model = new SomeModel(paramOne, paramTwo, paramThree);
       return new ModelAndView("SomeJsp", "model", model);
    } 
Run Code Online (Sandbox Code Playgroud)

SomeModel.java

public class SomeModel{
 private String paramOne;
 private String paramTwo;
 private String paramThree;
//constructor
 //setters and getters

}
Run Code Online (Sandbox Code Playgroud)

SomeJsp.jsp

//In this Jsp i have a div with few elements. Div is not visible by default.
//This jsp has externalJavascript included.
//I enable div and set the …
Run Code Online (Sandbox Code Playgroud)

javascript java jquery spring spring-mvc

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

propertiesfactorybean vs propertyplaceholderconfigurer spring?

spring有两种方法可以使用propertiesfactorybeanpropertyplaceholderconfigurer加载属性文件.

你可以解释一下它们之间的区别以及何时使用它们?

谢谢!

java spring

12
推荐指数
1
解决办法
4905
查看次数

Spring bean实例化通过传递构造函数args?

我有春豆.

public class Employee2 {

  private int id;
  private String name;
  private double salary;


  public Employee2(int id, String name, double salary) {
    this.id = id;
    this.name = name;
    this.salary = salary;
  }

 // some logic to call database using above values

}
Run Code Online (Sandbox Code Playgroud)

现在我在spring配置文件中有以下配置.

<bean id="emp2" class="com.basic.Employee2">
            <constructor-arg name="id" value="" />
            <constructor-arg name="name" value="" />
            <constructor-arg name="salary" value="" />
</bean>
Run Code Online (Sandbox Code Playgroud)

现在我不能硬编码上面配置中的值,因为它们是动态的.

现在我使用下面的代码以编程方式获取spring bean.豆的范围是singelton.

Employee2 emp = (Employee2)applicationContext.getBean("emp2");
Run Code Online (Sandbox Code Playgroud)

现在我如何将值传递给Employee2构造函数

谢谢!

java spring spring-mvc spring-3

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

使用JQuery为label分配值?

我正在使用JQuery 1.8.3.我有HTML标签以下.

<label for="myalue" style="vertical-align: middle"></label>
Run Code Online (Sandbox Code Playgroud)

现在使用JQuery我需要将一个字符串设置为上面的标签,我尝试如下.

 $("label[for='myalue']").text("someText");
Run Code Online (Sandbox Code Playgroud)

以上代码仅适用于IE.但是在Firefox标签中没有设置值.

有什么建议?

谢谢!

html javascript jquery

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

关于javax.persistence JAR的Maven依赖关系?

我使用的是Spring 3和Hibernate 4 JPA.我对javax.persistence JAR 很困惑.我在Google下面找到了两个Maven依赖项.请告诉我以下两个依赖项需要哪一个?

       <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0.2</version>
        </dependency>

       <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.0.0</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

java spring hibernate jpa maven

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

如何调用Oracle MD5哈希函数?

我有以下代码.我正在使用Oracle 11g.

SELECT DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(
  FIRST_NAME
  ||LAST_NAME
  )) md5_key ,
  FIRST_NAME ,
  LAST_NAME
FROM C_NAME_TAB
WHERE PKEY='1234'
Run Code Online (Sandbox Code Playgroud)

我怎么称这个代码?我可以直接在sqldeveloper中执行此代码吗?

sql oracle plsql oracle11g

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