我正在查看所有弹簧休息注释,但我想在页面加载时触发?是这些中的任何一种,还是完全不同的东西。我正在使用REST模型查看无论什么方法。
org.springframework.data.rest.repository.annotation.HandleBeforeSave (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.RepositoryEventHandler (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleAfterDelete (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleBeforeRenderResources (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleAfterLinkSave (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleBeforeLinkSave (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleAfterSave (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleBeforeLinkDelete (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.RestResource (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleBeforeDelete (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.ConvertWith (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleAfterLinkDelete (implements java.lang.annotation.Annotation)
org.springframework.data.rest.repository.annotation.HandleBeforeRenderResource (implements java.lang.annotation.Annotation)
当页面加载时,我需要在Java中发生一些事情。
@RepositoryEventHandler(myObject.class)
public class myIntuitObjectEventHandler {
com.intuit.ipp.data.myIntuitObject[] mio;
@Autowired
private myObjectRepository myObjectRepository;
@HandleAfterCreate
public void handleBeforeCreate() {
logger.out("Handle Before Create!");
}
}
答案 0 :(得分:0)
选项#1:在获取页面时使用请求映射。这样,每次用户向该控制器发出请求时都会调用它。例如,每次用户点击 localhost:8080 / yourApp / yourService 时,都会调用以下方法。
@RequestMapping(value="/yourService", method=RequestMethod.GET)
public String someMethod() { . . . };
选项#2:根据您的需要,通过以下任一事件的AJAX调用,通过客户端进行服务调用。
$(window).load(function() { . . .});
$(document).ready(function(){ . . . });