springMVC过滤器过滤文件上传,获取参数为空

weixin_38066001 2013-05-31 01:08:17
 开发四年只会写业务代码,分布式高并发都不会还做程序员?->>>    使用springMVC,图片上传,过滤器拦截获取不了请求参数。 页面发起的请求有三个参数:op,name,picture。 HTML代码如下: <form action="<%=request.getContextPath()%>/app" method="post" enctype="multipart/form-data"> op:<input name="op" value="user.regist" /><br/> 姓名(name):<input name="name" /><br/> 头像(picture):<input name="picture" type="file"><br/> <input type="submit"/> </form> 过滤器的实现的功能是获取op参数进行请求转发。 过滤器代码如下: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest)request; String op = httpRequest.getParameter("op"); op = op.replace(".", "/"); request.getRequestDispatcher("/app/"+op).forward(request, response); } 遇到的问题是表单的属性是enctype="multipart/form-data"时,过滤器取得的op值是null。 请教过滤器如何在表单属性enctype="multipart/form-data"时获取到op的值?是不是过滤器拦截到请求时表单还没有提交完毕,获取不了表单里面的值?求解决方案。
...全文
53 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧