NutzCN Logo
问答 根据返回值决定视图报错了
发布于 3314天前 作者 qq_e24e3d78 2613 次浏览 复制 上一个帖子 下一个帖子
标签:

代码

	@At("/login")
	@Ok("re:jsp:/jsp/login")
	public Object login(@Param("..")Map<String, Object> map,ViewModel modle,HttpSession session){
		String userName = map.get("name") != null ? String.valueOf(map.get("name")) : "";
		String pwd = map.get("pwd") != null ? String.valueOf(map.get("pwd")) : "";
		String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
		if(Strings.isBlank(userName)&&Strings.isBlank(pwd)&&Strings.isBlank(code)){
			
			return null;
		}

报错:

     java.lang.RuntimeException: Can not eval {}("{}") View for public java.lang.Object com.elx.web.module.UserModule.login(java.util.Map,org.nutz.mvc.Vi  ewModel,javax.servlet.http.HttpSession)
	at org.nutz.lang.Lang.makeThrow(Lang.java:99)
	at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:87)
	at org.nutz.mvc.view.ViewZone.render(ViewZone.java:46)
	at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:55)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:28)
	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:40)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
	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:40)
	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:183)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
	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)

6 回复

返回的内容是?

@wendal 没有返回内容。我就是想浏览器输入localhost:8080/demo/login直接进入登录界面,结果就报这些错误了。

我写了个测试方法

	@At("/re/view3")
	@Ok("re:jsp:jsp.home") // 这个jsp文件在 /WEB-INF/jsp/home.jsp
	public String test_re_view() {
		return null;
	}

是可以的呢

然后这一句

Can not eval {}("{}") View

对应源码里面的ViewZone.java 87行

throw Lang.makeThrow("Can not eval %s(\"%s\") View for %s", viewType, str, ai.getMethod());

所以, viewType的值是{}, 也就是返回值是"{}" 或者是个空的Map吧,我估计, 而不是你说的返回了null呢

@wendal jsp文件放在/WEB-INF下用

@Ok("re:jsp:jsp.login")
@Ok("re:jsp:jsp/login")

两种方法都可以访问到login.jsp页面,如果jsp文件放在/WEB-INF外面的话就都访问不到。

还记得jsp视图的规则不? 以/开头就是根开始算,否则就是/WEB-INF/开始算

@Ok("re:jsp:/login")
添加回复
请先登陆
回到顶部