NutzCN Logo
问答 form 提交表单数据和附件 报错
发布于 2618天前 作者 啊哈 2246 次浏览 复制 上一个帖子 下一个帖子
标签:
前台:<form action="/bxasafety/gov/user/query/index" method="post" enctype="multipart/form-data">
id:<input type="text" name="id1"/>
name <input type="text" name="name1"/>
file <input type="file" name="file"/>
<input type="submit" value="formsubmit">
</form>

后台
@At("/query/?")
@Ok("beetl:/aef/user/hello.html${p.mode == 'ajax' ? '#dataTable' :''}")
@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp","8192","UTF-8","10000"})
public Object query(@Param("..")NutMap record,HttpServletRequest req,HttpSession sess){

System.out.println(record);

}

报错了
java.lang.String cannot be cast to org.nutz.lang.util.NutMap

我怎么写才能正确接收表单数据和附件。

11 回复

按一下 插入代码 按钮会死吗?

难道看不到出什么效果吗? java代码就没按啊

前台:<form action="/bxasafety/gov/user/query/index" method="post" enctype="multipart/form-data">
id:<input type="text" name="id1"/>
name <input type="text" name="name1"/>
file <input type="file" name="file"/>
<input type="submit" value="formsubmit">
</form>
@At("/query/?")
    @Ok("beetl:/aef/user/hello.html${p.mode == 'ajax' ? '#dataTable' :''}")
    @AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp","8192","UTF-8","10000"})
    public Object query(@Param("..")NutMap record,HttpServletRequest req,HttpSession sess){

    	System.out.println(record);
}

报错了
java.lang.String cannot be cast to org.nutz.lang.util.NutMap

我怎么写才能正确接收表单数据和附件。

贴完整报错信息

2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:100)] [org.nutz.mvc.upload.FastUploading]:skip first boundary
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:111)] [org.nutz.mvc.upload.FastUploading]:Reading...
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133)] [org.nutz.mvc.upload.FastUploading]:Upload File info: FilePath=[null],fieldName=[id1]
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214)] [org.nutz.mvc.upload.FastUploading]:Found a param, name=[id1] value=[啊飞啊飞]
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133)] [org.nutz.mvc.upload.FastUploading]:Upload File info: FilePath=[null],fieldName=[name1]
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214)] [org.nutz.mvc.upload.FastUploading]:Found a param, name=[name1] value=[奥尔芬]
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133)] [org.nutz.mvc.upload.FastUploading]:Upload File info: FilePath=[风险点管理列表.txt],fieldName=[file]
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137)] [org.nutz.mvc.upload.FastUploading]:Upload Info: name=风险点管理列表.txt,content_type=text/plain
2017-09-15 10:33:52:[DEBUG][ org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:231)] [org.nutz.mvc.upload.FastUploading]:...Done 17041 bytes readed
2017-09-15 10:33:52:[WARN ][ org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28)] [org.nutz.mvc.impl.processor.FailProcessor]:Error@/gov/user/query/index :
java.lang.ClassCastException: java.lang.String cannot be cast to org.nutz.lang.util.NutMap
	at bxa.action.gov.UserAction$$FASTCLASS._invoke(UserAction.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	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:198)
	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:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	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:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

缺了路径参数

不懂啊。缺了哪路径参数啊,怎么修改啊。

@At里面有个问号,代表路径参数,入口方法的第一个参数需要匹配上

就在在最前面加一个参数,类型String

public void query(String name, @Param("..")NutMap record, ...........)
添加回复
请先登陆
回到顶部