首页 新闻 搜索 专区 学院

spring mvc

0
悬赏园豆:30 [待解决问题]

jsp页面的a标签怎样传值到controller层啊,我在controller获取的值是空的啊

低头、深拥的主页 低头、深拥 | 初学一级 | 园豆:57
提问于:2018-01-09 13:41
< >
分享
所有回答(3)
0

你是地址后面的参数吗 ?

比如这样 href="xxxxxxxx?a=x&b=y"

Controller中这么接收就行

public ModelAndView handleRequest(HttpServletRequest req) throws Exception {
ModelAndView mv = new ModelAndView();
mv.addObject("x", req.getParameter("x"));//req.getParameter("key1")是取得key1的值
mv.addObject("y", req.getParameter("y"));
mv.setViewName("login/login.jsp");
return mv;
}
如果不对请告诉我 谢啦
九河中钓麻花 | 园豆:173 (初学一级) | 2018-01-09 15:50

不是应该用@requestMappering和@Controller写的吗

支持(0) 反对(0) 低头、深拥 | 园豆:57 (初学一级) | 2018-01-09 17:49
0
@Controller
@RequestMapping(value = "/login")
public class LoginController {
    @RequestMapping(value = "save", method = RequestMethod.GET)
    public string save(String userName, String password) {
  // 你的逻辑  
}
}
~冰 | 园豆:497 (菜鸟二级) | 2018-01-10 11:52

是不是给a标签加一个name属性

支持(0) 反对(0) 流年飞雨 | 园豆:1978 (小虾三级) | 2018-01-11 10:40
0

@RequestMapping(value="/goto/entry/{flowType}", method = { RequestMethod.GET })

public String gotoApplyPage(Model model, String appExpressApplyId, @PathVariable("flowType") ExpressFlowTypeEnum flowType) {

setApplyPageModleProperties(model);

switch (flowType) {

case NEW_CUSTOMER_APPLY:

model.addAttribute("ExpressLoanProducts", BusinessType.values());

model.addAttribute("applyDetail", appPreReviewApiImpl.getExpressFirstTrialDTO4Entry(appExpressApplyId));

return "page/express/apply/newCustomerApply";

case RENEW_APPLY:

model.addAttribute("ExpressLoanProducts", BusinessType.values());

model.addAttribute("applyDetail", appPreReviewApiImpl.getExpressFirstTrialDTO4Renew(appExpressApplyId));

model.addAttribute("title", "续签");

return "page/express/apply/renewApply";

default:

throw WebException.instance("不支持的流程类型");

}

}

 

 

 

 

@RequestMapping(value = "/getContractDate", method = { RequestMethod.POST })

@ResponseBody

public ObjectResult<?> getContractDate(String companyId) {

try {

return ObjectResult.success("获取合同期限成功", expressContractApiImpl.getExpressContractByCustomerId(companyId));

} catch (Exception e) {

return FrontExceptionHandler.handleObjectResultException(e);

}

}

 

 

一个get  一个post  项目里copy的,将就着看吧

让我发会呆 | 园豆:2636 (老鸟四级) | 2018-01-10 11:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册