首页上一页 1 下一页尾页 9 条记录 1/1页
关于JAVA WED开发实战第18章Spring+Hibernate实现用户管理模块代码段的问题
发表在JavaWeb图书答疑
2015-01-18
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
在工程userManagerModule中的FileUpload.java中,
在public Map upload(HttpServletRequest request, HttpServletResponse response)
throws Exception {}
List items = upload.parseRequest(request);// 解析请求信息
这句有提示出问题。在项目运行后,添加、保存不了。
在public Map upload(HttpServletRequest request, HttpServletResponse response)
throws Exception {}
List items = upload.parseRequest(request);// 解析请求信息
这句有提示出问题。在项目运行后,添加、保存不了。
精彩评论 9
2015-01-19
板凳
List items = upload.parseRequest(request);// 解析请求信息
这一句在程序未运行ECLIPSE就显示有问题。
运行后,添加、保存不了。
以下是运行后,添加时出现的错误的提示;
一月 19, 2015 8:56:22 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [dispatcherServlet] in context with path [/userManagerModule] threw exception [Handler processing failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method parseRequest(RequestContext) in the type FileUploadBase is not applicable for the arguments (HttpServletRequest)
] with root cause
java.lang.Error: Unresolved compilation problem:
The method parseRequest(RequestContext) in the type FileUploadBase is not applicable for the arguments (HttpServletRequest)
at com.jwy.cotroller.FileUpload.upload(FileUpload.java:40)
at com.jwy.cotroller.UserOperationController.insertUser(UserOperationController.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
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)
这一句在程序未运行ECLIPSE就显示有问题。
运行后,添加、保存不了。
以下是运行后,添加时出现的错误的提示;
一月 19, 2015 8:56:22 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [dispatcherServlet] in context with path [/userManagerModule] threw exception [Handler processing failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method parseRequest(RequestContext) in the type FileUploadBase is not applicable for the arguments (HttpServletRequest)
] with root cause
java.lang.Error: Unresolved compilation problem:
The method parseRequest(RequestContext) in the type FileUploadBase is not applicable for the arguments (HttpServletRequest)
at com.jwy.cotroller.FileUpload.upload(FileUpload.java:40)
at com.jwy.cotroller.UserOperationController.insertUser(UserOperationController.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
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)
2015-01-21
地板
在前台JSP页面里谁知form表单
<form action="a.jsp" encType="multipart/form-data" method="post">
或者修改为
boolean isMultipart = upload.isMultipartContent(request); //请求是否包含多部分内容
if (isMultipart) {
try {
list = upload.parseRequest(request);
} catch (FileUploadException e1) {
e1.printStackTrace();
}
}else{
/*网络异常*/
}
<form action="a.jsp" encType="multipart/form-data" method="post">
或者修改为
boolean isMultipart = upload.isMultipartContent(request); //请求是否包含多部分内容
if (isMultipart) {
try {
list = upload.parseRequest(request);
} catch (FileUploadException e1) {
e1.printStackTrace();
}
}else{
/*网络异常*/
}
2015-01-22
7L
第一问:在前台JSP页面里设置form表单
<form action="a.jsp" encType="multipart/form-data" method="post">
是设置什么表单。我想应该是insertUser.jsp吧,
但insertUser.jsp的form是以下句子。
<form name="f1" action="userOperation.html?method=insertUser"
method="post" enctype="multipart/form-data" onSubmit="return check()">
如果改成<form action="a.jsp" encType="multipart/form-data" method="post">出错。
第二问:
或者修改为
boolean isMultipart = upload.isMultipartContent(request); //请求是否包含多部分内容
if (isMultipart) {
try {
list = upload.parseRequest(request);
} catch (FileUploadException e1) {
e1.printStackTrace();
}
}else{
/*网络异常*/
}
以上内容在哪里修改。
第三问:项目已出现红叉,原因是FileUpload.java中的
List items = upload.parseRequest(request);这句无法编译。
我个人感觉应是改这里吧。不知对不对,请指导。
<form action="a.jsp" encType="multipart/form-data" method="post">
是设置什么表单。我想应该是insertUser.jsp吧,
但insertUser.jsp的form是以下句子。
<form name="f1" action="userOperation.html?method=insertUser"
method="post" enctype="multipart/form-data" onSubmit="return check()">
如果改成<form action="a.jsp" encType="multipart/form-data" method="post">出错。
第二问:
或者修改为
boolean isMultipart = upload.isMultipartContent(request); //请求是否包含多部分内容
if (isMultipart) {
try {
list = upload.parseRequest(request);
} catch (FileUploadException e1) {
e1.printStackTrace();
}
}else{
/*网络异常*/
}
以上内容在哪里修改。
第三问:项目已出现红叉,原因是FileUpload.java中的
List items = upload.parseRequest(request);这句无法编译。
我个人感觉应是改这里吧。不知对不对,请指导。
2015-01-23
8L
请把FileUpload.java文件中的
import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
修改成
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
然后把文件上传的Jar包commons-fileupload-1.2.1.jar和commons-io-1.4.jar添加到项目的构建路径中就可以了。
import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
修改成
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
然后把文件上传的Jar包commons-fileupload-1.2.1.jar和commons-io-1.4.jar添加到项目的构建路径中就可以了。