在JSP我如何从URL获取参数?
例如,我有一个URL www.somesite.com/Transaction_List.jsp?accountID=5 我要得到5。 有什么要求吗?getAttribute("accountID")就像有会话或类似的东西吗?
在JSP我如何从URL获取参数?
例如,我有一个URL www.somesite.com/Transaction_List.jsp?accountID=5 我要得到5。 有什么要求吗?getAttribute("accountID")就像有会话或类似的东西吗?
当前回答
示例:您想删除带有subject_id的主题记录
@RequestMapping(value="subject_setup/delete/{subjectid}",method = RequestMethod.GET)
public ModelAndView delete(@PathVariable int subjectid) {
subjectsDao.delete(subjectid);
return new ModelAndView("redirect:/subject_setup");
}
该参数将用于查询的输入
public int delete(int subjectid) {
String sql = "update tbl_subject set isdeleted= '1' where id = "+subjectid+"";
return template.update(sql);
}
其他回答
第一页: 细节 第二页: <% String id = request.getParameter("userid") //现在您可以使用id查询HSQL详细产品
如果我可以在这里补充评论的话……
< c: value = " $ {param.accountID} " > < / c: >
对我不起作用(它输出0)。
相反,这是可行的:
< c: value = " ${参数[' accountID ']} " > < / c: >
request.getParameter("accountID")就是你要找的。这是Java Servlet API的一部分。更多信息请参见http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html。
示例:您想删除带有subject_id的主题记录
@RequestMapping(value="subject_setup/delete/{subjectid}",method = RequestMethod.GET)
public ModelAndView delete(@PathVariable int subjectid) {
subjectsDao.delete(subjectid);
return new ModelAndView("redirect:/subject_setup");
}
该参数将用于查询的输入
public int delete(int subjectid) {
String sql = "update tbl_subject set isdeleted= '1' where id = "+subjectid+"";
return template.update(sql);
}
使用EL (JSP表达式语言):
$ {param.accountID}