jsp页面的a标签怎样传值到controller层啊,我在controller获取的值是空的啊
你是地址后面的参数吗 ?
比如这样 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;
}
不是应该用@requestMappering和@Controller写的吗
@Controller @RequestMapping(value = "/login") public class LoginController { @RequestMapping(value = "save", method = RequestMethod.GET) public string save(String userName, String password) { // 你的逻辑 }
}
是不是给a标签加一个name属性
@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的,将就着看吧