不多说,上代码。
这是config:
public void config() {
// TODO Auto-generated method stub
add("/api/user", UserController.class);
add("/api/userInfo", UserInfoController.class);
}
这是UserController
@Before(UserValidator.class)
public void add() {
UserAccount ua = getModel(UserAccount.class);
boolean bool = ua.save();
if(bool){
ua = getModel(UserAccount.class);
Result(200, ua);
}else{
Result(503);
}
}
这是请求路径:http://localhost:8080/api/user 错误描述:
[ERROR]-[Thread: http-8080-1]-[com.jfinal.core.ActionHandler.handle()]: /api/user
com.jfinal.render.RenderException: java.io.FileNotFoundException: Template "/api/user/index.html" not found.
at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:147)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:97)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Template "/api/user/index.html" not found.
at freemarker.template.Configuration.getTemplate(Configuration.java:742)
at freemarker.template.Configuration.getTemplate(Configuration.java:665)
at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:143)
... 14 more