本文整理了Java中org.kohsuke.stapler.StaplerRequest.getWebApp()
方法的一些代码示例,展示了StaplerRequest.getWebApp()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getWebApp()
方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getWebApp
[英]Short for getStapler().getWebApp()
[中]GetStapper()的缩写。getWebApp()
代码示例来源:origin: stapler/stapler
/**
* Includes another view.
*/
public void include(Object it, String view) throws IOException, JellyException {
_include(it,request.getWebApp().getKlass(it),view);
}
代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly
protected JellyContext createContext(final StaplerRequest req, StaplerResponse rsp, Script script, Object it) {
CustomJellyContext context = new CustomJellyContext();
// let Jelly see the whole classes
context.setClassLoader(req.getWebApp().getClassLoader());
// so TagScript.getBodyText() will use HTMLWriterOutput
context.setVariable(XMLOutputFactory.class.getName(), this);
return context;
}
代码示例来源:origin: stapler/stapler
protected JellyContext createContext(final StaplerRequest req, StaplerResponse rsp, Script script, Object it) {
CustomJellyContext context = new CustomJellyContext();
// let Jelly see the whole classes
context.setClassLoader(req.getWebApp().getClassLoader());
// so TagScript.getBodyText() will use HTMLWriterOutput
context.setVariable(XMLOutputFactory.class.getName(), this);
return context;
}
代码示例来源:origin: stapler/stapler
private void _include(Object it, Klass clazz, String view) throws IOException, JellyException {
JellyClassTearOff t = request.getWebApp().getMetaClass(clazz).loadTearOff(JellyClassTearOff.class);
Script s = t.findScript(view);
if(s==null)
throw new IllegalArgumentException("No such view: "+view+" for "+clazz);
JellyContext context = new JellyContext(getContext());
if(it!=null)
context.setVariable("it",it);
context.setVariable("from", it);
ClassLoader old = Thread.currentThread().getContextClassLoader();
if (clazz.clazz instanceof Class)
Thread.currentThread().setContextClassLoader(((Class)clazz.clazz).getClassLoader());
try {
s.run(context,output);
} finally {
Thread.currentThread().setContextClassLoader(old);
}
}
代码示例来源:origin: org.kohsuke.stapler/stapler
@Override
public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments)
throws IllegalAccessException, InvocationTargetException, ServletException {
if (!request.getMethod().equals("POST")) {
for (ErrorCustomizer handler : ServiceLoader.load(ErrorCustomizer.class, request.getWebApp().getClassLoader())) {
ForwardToView forwardToView = handler.getForwardView();
if (forwardToView != null) {
throw new InvocationTargetException(forwardToView.with("requestURL", request.getRequestURLWithQueryString().toString()));
}
}
throw new InvocationTargetException(new HttpResponses.HttpResponseException() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
rsp.addHeader("Allow", "POST");
rsp.setContentType("text/html");
PrintWriter w = rsp.getWriter();
w.println("<html><head><title>POST required</title></head><body>");
w.println("POST is required for " + target.getQualifiedName() + "<br>");
w.println("<form method='POST'><input type='submit' value='Try POSTing'></form>");
w.println("</body></html>");
}
});
}
return target.invoke(request, response, instance, arguments);
}
}
代码示例来源:origin: stapler/stapler
@Override
public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments)
throws IllegalAccessException, InvocationTargetException, ServletException {
if (!request.getMethod().equals("POST")) {
for (ErrorCustomizer handler : ServiceLoader.load(ErrorCustomizer.class, request.getWebApp().getClassLoader())) {
ForwardToView forwardToView = handler.getForwardView();
if (forwardToView != null) {
throw new InvocationTargetException(forwardToView.with("requestURL", request.getRequestURLWithQueryString().toString()));
}
}
throw new InvocationTargetException(new HttpResponses.HttpResponseException() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
rsp.addHeader("Allow", "POST");
rsp.setContentType("text/html");
PrintWriter w = rsp.getWriter();
w.println("<html><head><title>POST required</title></head><body>");
w.println("POST is required for " + target.getQualifiedName() + "<br>");
w.println("<form method='POST'><input type='submit' value='Try POSTing'></form>");
w.println("</body></html>");
}
});
}
return target.invoke(request, response, instance, arguments);
}
}
代码示例来源:origin: stapler/stapler
public void doIndex(StaplerRequest req,StaplerResponse rsp) throws IOException {
rsp.setContentType("text/html");
String crumb = req.getWebApp().getCrumbIssuer().issueCrumb();
PrintWriter w = rsp.getWriter();
w.println("<html><body><script src='prototype'></script><script src='script'></script>");
w.println("<script>var v = makeStaplerProxy('/','"+crumb+"',['foo','bar']);var callback = function(t){var x=t.responseObject();alert(typeof(x)+':'+x)};</script>");
w.println("</body></html>");
}
内容来源于网络,如有侵权,请联系作者删除!