springMVC controller间跳转

      本人ssm初学者,学习过程中遇到这个问题:我需要插入或者修改一条数据,我想要的需求是插入成功后立马跳转到全部数据页面,而不是空数据的jsp页面,之前只知道controller 中的方法return 的String只能是逻辑视图jsp页面,后来百度才知道可以controller内方法之间跳转。

总结就是:  

内部跳转 :  return "forward:/aaaa/bbbb.do"

重定向跳转 :return "redirect:/aaaa/bbbb.do";

这是我的查询全部数据的方法:

@RequestMapping("list.do")
	public String list(QueryVo vo,Model model) {

		
		List<Customer> listAll = customerService.selectPageByQueryVo(vo);
		model.addAttribute("listAll", listAll);
		
		model.addAttribute("custName", vo.getCustName());
		model.addAttribute("custSource",vo.getCustSource());
		model.addAttribute("custIndustry", vo.getCustIndustry());
		model.addAttribute("custLevel", vo.getCustLevel());
		return "list";
			

这是原来的插入数据方法:返回的是空数据list.jsp

@RequestMapping(value="save.do")
	public  String save( Customer customer){
		customerService.saveCustomer(customer);
		return "list"; 
		
	}

修改之后的:成功实现方法间跳转

@RequestMapping(value="save.do")
	public String save( Customer customer){
		customerService.saveCustomer(customer);
		return "redirect:/customer/list.do";
		
	}


SpringMVC controller 无法访问

12-03

项目是SpringMVC Maven结构的rnindex.jsp 页面可以正常访问,访问controller的 地址却一直是404,各路大神 帮忙看下。。。rncontroller访问地址:http://localhost:8080/clt/larw/verify?signature=signature&timestamp=timestamp&nonce=nonce&echostr=echostrrn[b]web.xml[/b]rn[code=text]rnrn rn rn contextConfigLocationrn /WEB-INF/config/spring-root.xmlrn rn rn rn org.springframework.web.context.ContextLoaderListenerrn rn rn rn springmvcrn org.springframework.web.servlet.DispatcherServletrn rn contextConfigLocationrn /WEB-INF/config/spring-servlet.xmlrn rn 1rn truern rn rn springmvcrn /rn rn[/code]rnrn[b]spring-root.xml[/b] 现在是个空文件rnrn[b]spring-servlet.xml[/b]rn[code=text]rnrnrn rn rnrn rn rn rn rn rn rn rn rnrn rn rnrn rn rnrn rn rnrn[/code]rnrn[b]spring-controllers.xml[/b]rn[code=text]rnrn rn rn rn rn rn rn rnrn rn[/code]rnrn[b]test controller[/b]rn[code=java]package org.clt.controller;rnrnimport org.clt.service.WechatService;rnimport org.springframework.beans.factory.annotation.Autowired;rnimport org.springframework.stereotype.Controller;rnimport org.springframework.web.bind.annotation.RequestMapping;rnimport org.springframework.web.bind.annotation.RequestMethod;rnimport org.springframework.web.bind.annotation.RequestParam;rnrn@Controllerrn@RequestMapping("/larw")rnpublic class WechatListener rn rn @Autowiredrn private WechatService wechatService;rn rn @RequestMapping(value="/verify", method=RequestMethod.GET)rn public String verification(@RequestParam String signature,@RequestParam String timestamp,rn @RequestParam String nonce, @RequestParam String echostr) rn System.out.println("-----------------come in WechatListener-----------------");rn rn String result = null;rn Boolean flag = wechatService.verifyWechatConfig(signature, timestamp, nonce);rn rn return flag ? echostr : result;rn rnrn[/code]rnrn

SpringMVC注解方式找不到controller

03-12

rn rn rn rn rn rn rn rnrnrncontroller代码:rnpackage demo.controller;rnrnimport javax.annotation.Resource;rnrnimport org.springframework.stereotype.Controller;rnimport org.springframework.ui.Model;rnimport org.springframework.web.bind.annotation.RequestMapping;rnimport org.springframework.web.servlet.mvc.multiaction.MultiActionController;rnrnimport demo.service.IserviceEMP;rnimport demo.vo.Emps;rn@Controllerrn@RequestMapping("/text")rnpublic class MyLoginController extends MultiActionControllerrn @Resource(name="serviceImple")rn private IserviceEMP serviceemp;rn rn rn public IserviceEMP getServiceemp() rn return serviceemp;rn rnrnrn public void setServiceemp(IserviceEMP serviceemp) rn this.serviceemp = serviceemp;rn rnrnrn @RequestMapping("/loginemp.action")rn public String loginEmp(Emps emps,Model m)rn System.out.println(emps.getPass());rn if(emps.getPass().equals(serviceemp.selectByLoginNameAndPassword(emps.getName()))) rn return "succ"; rn rn return "index";rn rn rnrnrnService代码:rnpackage demo.service;rnrnimport java.util.List;rnrnimport javax.annotation.Resource;rnimport org.springframework.stereotype.Service;rnimport demo.dao.IempsDao;rnimport demo.vo.Emps;rnrn@Servicernpublic class ServiceImple implements IserviceEMP rn @Resource(name="empsDaoImpl")rn private IempsDao dao;rn @Overridern public String selectByLoginNameAndPassword(String name) rn Emps emp=dao.selectByLoginNameAndPassword(name);rn return emp.getPass();rn rn @Overridern public List serviceSelectEmp() rn return dao.selectEmp(); rn rn @Overridern public void serviceDeleteEmp(int id) rn dao.deleteEmp(id); rn rn public IempsDao getDao() rn return dao;rn rn public void setDao(IempsDao dao) rn this.dao = dao;rn rnrn[img=http://img.bbs.csdn.net/upload/201703/12/1489285979_959846.jpg][/img]rnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试