我已经创建了一个 jsp 页面,我从中获取一些值并在提交时应该使用 rest 将参数传递给 java 类。
<form id="payment" method="post" action="addtogroup">
<ol style="padding: 0;">
<li><label for="groupId">组id:</label>
< input type="text" id="groupId" name="groupId"/>
<br />
<li><label for="vendorId">个人资料ID:</label>
< input type="text" id="vendorId" name="vendorId"/>
<li> < input type="submit" value="Submit"/> <br /></ol>
</form>
Java代码是:
@RequestMapping(value = "/addtogroup/{groupId}/{vendorId}",method = RequestMethod.POST)
public String addtoGroup(@ModelAttribute("groupId") String groupId,@ModelAttribute("vendorId") String profileId){
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
System.out.println("group id is="+groupId);
System.out.println("profileId is="+profileId);
System.out.println("username is="+username);
grpDao.addToGroup(groupId,profileId,username);
return "addtogroup";
}
当我直接在地址栏中键入 [http://localhost:8080/biznex/rest/addtogroup/2/13] 时,代码被执行。但是当我单击jsp中的提交按钮时,我得到页面未找到错误。请帮帮我。