问题描述
刚学习用srpingMVC遇见这个问题两天了求大神帮助下啊QQ463042360web.xmlapplicationContext-mvc.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:p="http://www.springframework.org/schema/p"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"><mvc:annotation-driven></mvc:annotation-driven><context:component-scanbase-package="com.iuxia.controller"></context:component-scan><mvc:default-servlet-handler/><mvc:annotation-drivencontent-negotiation-manager="contentNegotiationManager"><!--配置SpringMVC返回中文乱码--><mvc:message-convertersregister-defaults="true"><!--将StringHttpMessageCOnverter的默认编码设为UTF-8--><beanclass="org.springframework.http.converter.StringHttpMessageConverter"><constructor-argvalue="UTF-8"/></bean></mvc:message-converters><!--扩展传多个对象如user.nameuser1.name--><mvc:argument-resolvers><beanclass="com.iuxia.framework.annotation.FormModelMethodArgumentResolver"/><beanclass="com.iuxia.framework.annotation.RequestJsonParamMethodArgumentResolver"/></mvc:argument-resolvers></mvc:annotation-driven><!--视图解释类--><beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="prefix"value="/WEB-INF/views/"/><propertyname="suffix"value=".jsp"/><!--可为空,方便实现自已的依据扩展名来选择视图解释类的逻辑--><propertyname="viewClass"value="org.springframework.web.servlet.view.JstlView"/></bean><!--REST中根据URL后缀自动判定Content-Type及相应的View--><beanid="contentNegotiationManager"class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"><propertyname="mediaTypes"><value>json=application/jsonxml=application/xml</value></property></bean><!--对静态资源文件的访问方案一--><mvc:default-servlet-handler/><!--避免IE在ajax请求时,返回json出现下载--><beanid="jacksonMessageConverter"class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"><propertyname="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean><!--这里申明的id必须为multipartResolver--><beanid="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"p:defaultEncoding="utf-8"/></beans>packagecom.iuxia.controller.axuser;importjava.util.HashMap;importjava.util.List;importjava.util.Map;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Controller;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.servlet.ModelAndView;importcom.iuxia.base.model.PageConfig;importcom.iuxia.base.util.StringUtil;importcom.iuxia.controller.base.BaseController;importcom.iuxia.entity.Axuser;importcom.iuxia.framework.annotation.FormModel;importcom.iuxia.services.axuser.AxusersService;@Controller@RequestMapping("/axuser")publicclassAxusersControllerextendsBaseController{@AutowiredprivateAxusersServiceaxusersService;@RequestMapping(value="/index")publicModelAndViewindex(HttpServletRequestrequest,HttpServletResponseresponse,@FormModel("axuser")Axuseraxuser){ModelAndViewmav=newModelAndView();mav.setViewName("index");returnmav;}@RequestMapping(value="/userList")publicModelAndViewuserList(HttpServletRequestrequest,HttpServletResponseresponse,@FormModel("axuser")Axuseraxuser){ModelAndViewmav=newModelAndView();//分页开始//pageNum当前页码//numPerPage每页大小intpageNum=StringUtil.parseInt(request.getParameter("pageNum"));intnumPerPage=StringUtil.parseInt(request.getParameter("numPerPage"));if(pageNum==0){pageNum=1;}if(numPerPage==0){numPerPage=25;}Map<String,Object>maps=newHashMap<String,Object>();maps.put("pagestart",(pageNum-1)*numPerPage);maps.put("pagesize",numPerPage);if(!StringUtil.empty(axuser.getUsername())){maps.put("username",axuser.getUsername());}inttotalCount=axusersService.getCount(maps);List<Object>list=axusersService.getList(maps);PageConfigpageConfig=newPageConfig(numPerPage,totalCount,pageNum,10,list);mav.addObject("pageConfig",pageConfig);mav.setViewName("background/axuser/usersList");returnmav;}}访问方法http://localhost:8080/IUXiaManager/axuser/index
解决方案
解决方案二:
试试:classpath*:spring/applicationContext-mvc.xml
解决方案三:
楼主解决了没有?