NutzCN Logo
问答 关于hotplug如何调用插件中的jsp
发布于 62天前 作者 老司机 102 次浏览 复制 上一个帖子 下一个帖子
标签:

如题:我的插件是这样的

public class YvrMainModule {
    @Ok("jsp:jsp.index")
    @At("/yvr/test")
    public void test() {
        System.out.println("YvrModule成功访问!");
    }
}

jsp放在插件项目的main\resources\templates\yvr\jsp\index.jsp
现在测试访问时成功了,但是jsp显示404,它去访问webapp的/WEB-INF/jsp/index.jsp了,我要访问插件里的index.jsp怎么写?

12 回复

写不了,得用模板

@wendal 那用模板的话,shiro的jsp标签岂不是用不了?那怎么控制页面呢?

能啊,例如beetl,@shiro.hasRole

@wendal
我的webapp

@IocBy(args = {})
@Modules(scanPackage = false)
@LoadingBy(Hotplug.class)
@SetupBy(MainSetup.class)
@Views({BeetlViewMaker.class})
public class MainModule {
    @Ok("http:200")
    @At
    public void test() {
    }
}

yvr

public class YvrMainModule {
    @Ok("beetl:yvr.index")
    @At("/yvr/test")
    public void test() {
        System.out.println("YvrModule成功访问!");
    }
}

index.html放在yvr\src\main\resources\templates\yvr\index.html,还是访问不到为啥啊?报错:

YvrModule成功访问!
TEMPLATE_LOAD_ERROR
	at org.beetl.core.resource.FileResource.openReader(FileResource.java:45)
	at org.beetl.core.GroupTemplate.loadTemplate(GroupTemplate.java:632)
	at org.beetl.core.GroupTemplate.getTemplateByLoader(GroupTemplate.java:582)
	at org.beetl.core.GroupTemplate.getTemplate(GroupTemplate.java:546)
	at org.beetl.ext.web.WebRender.render(WebRender.java:85)
	at org.beetl.ext.nutz.BeetlView.render(BeetlView.java:28)
	at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:66)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
17-10-10 13:53:05.927 DEBUG [http-nio-8080-exec-4]  模板根目录为 E:\Projects\Private\nutz-hotplug\hotplugtest\webapp\target\webapp\
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
>>01:53:05:错找不到指定模板或者加载错(TEMPLATE_LOAD_ERROR): 位于0行 资源:yvr.index 模板根目录为 E:\Projects\Private\nutz-hotplug\hotplugtest\webapp\target\webapp\
WebAppResourceLoader,Root=E:\Projects\Private\nutz-hotplug\hotplugtest\webapp\target\webapp\
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1374)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

参考nutzcn的beetl.properties

@wendal 添加了beetl.properties,但还是指向webapp\target\webapp\WEB-INF\templates并不指向插件的templates

里面有resource loader配置

@wendal 现在页面已经出来了,但是外联的css和js无法载入,怎么载入啊?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="${base}/assets/yvr/css/index.css">
</head>
<body>
<span class="green">Yvr插件页面调用成功</span>
</body>
</html>

css位置yvr\src\main\resources\assets\yvr\css

web.xml配了HotplugFilter没

@wendal 这个问题解决了,那么怎么解决部署时候的访问路径问题呢?
在idea里面运行能访问到是因为hotplug.properties里面配置了hotplug.parent_projects=E:/Projects/Private/nutz-hotplug/hotplugtest,然后去这个目录下面找插件文件夹,但部署的时候插件都是lib下面的jar包,那么这时候怎么办呢?

部署的时候去掉hotplug.parent_projects设置嘛。。。

再说了,如果设置的路径不存在,也会从jar加载,这样部署也不会有问题

添加回复
请先登陆
回到顶部