关于springmvc的问题

sinat_32311757 2015-10-26 09:18:32
我使用的是springmvc框架,在项目启动后,首次发送url请求的时候,控制台输出如下。
2015-10-24 20:27:44 [org.springframework.web.servlet.DispatcherServlet]-[INFO] FrameworkServlet 'ssdlxt': initialization started
2015-10-24 20:27:44 [org.springframework.web.context.support.XmlWebApplicationContext]-[INFO] Refreshing WebApplicationContext for namespace 'ssdlxt-servlet': startup date [Sat Oct 24 20:27:44 CST 2015]; parent: Root WebApplicationContext
2015-10-24 20:27:44 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from file [/Users/zhukally/Documents/apache-tomcat-7.0.64/webapps/ssdlxt/WEB-INF/classes/config/ssdlxt-servlet.xml]
2015-10-24 20:27:44 [org.springframework.context.annotation.ClassPathBeanDefinitionScanner]-[INFO] JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
2015-10-24 20:27:44 [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[INFO] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5f03ed7f: 2015-10-24 20:27:44 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]-[INFO] Mapped "{[/acl/roleSave.html],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.laymore.controller.acl.AclRoleController.roleSave(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,com.laymore.domain.AclRoleCommand,org.springframework.web.servlet.mvc.support.RedirectAttributes) throws java.lang.Exception
,不知道为什么最后会带有个java.lang.Exception异常。

以下是java后台代码:
@Controller
@RequestMapping(value="/acl")
public class AclUserController extends BaseController{
@RequestMapping(value="userManage.html")
public ModelAndView userManage(HttpServletRequest request,@ModelAttribute AclUserCommand command,HttpServletResponse response)throws Exception{
ModelAndView mv = new ModelAndView("acl/userList.jsp");
return mv;
}
@RequestMapping(value="getUserList.html")
public ModelAndView getUserList(HttpServletRequest request,@ModelAttribute AclUserCommand command,HttpServletResponse response)throws Exception{
IAclUserService aclUserService = (IAclUserService)ProjectContext.getBean("aclUserService");
String currentPage = request.getParameter("page");//jquery-easyui 传递的参数 第几页
int pageSize = Integer.parseInt(request.getParameter("rows"));//jquery-easyui 传递的参数 每页数量
super.setPageSize(pageSize);
super.setPageIndex(currentPage);//第几页,同时设置startIndex
UserInfo userInfo = (UserInfo)request.getSession().getAttribute("userInfo");
command.setUserInfo(userInfo);
PaginationSupport ps = aclUserService.findAclUserByPagination(super.getPageSize(), super.getStartIndex(), command);
return mv;
}
...全文
133 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinat_32311757 2015-10-26
  • 打赏
  • 举报
回复
@执笔记忆的空白 确实是因为throws Exception的问题,非常感觉
  • 打赏
  • 举报
回复
你去掉方法上面的throws Exception 看看出什么问题
sinat_32311757 2015-10-26
  • 打赏
  • 举报
回复
@执笔记忆的空白 只是在web启动后首次访问请求的时候会报这个错,之后任何url请求都不会报错了,而且系统运行正常。 roleSave代码: @RequestMapping(value="roleSave.html") public ModelAndView roleSave(HttpServletRequest request,HttpServletResponse response,@ModelAttribute AclRoleCommand command,RedirectAttributes redirectAttributes)throws Exception{ IAclRoleService aclRoleService = ServiceLoader.getIAclRoleService(); UserInfo userInfo = (UserInfo)request.getSession().getAttribute("userInfo"); command.setUserInfo(userInfo); response.setContentType("text/html;charset=UTF-8;"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); String ret = ""; try{ aclRoleService.saveRole(command); ret = "{\"result\":\"success\",\"msg\":\"操作成功\"}"; out.write(ret); }catch (Exception e) { e.printStackTrace(); ret = "{\"result\":\"fail\",\"msg\":\"操作失败\"}"; out.write(ret); }finally{ out.flush(); out.close(); } return null; }
sft0809 2015-10-26
  • 打赏
  • 举报
回复
配置文件的控制器铁出来
  • 打赏
  • 举报
回复
AclRoleController.roleSave(); 你看下你这个控制器的角色保存方法

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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