我正在网上开店,...有人可以告诉我为什么这段代码不起作用?
如果我在没有IF的情况下编写SQL语句,那么它工作正常,但我必须检查我选择的是哪个手机。
PhoneController:
def GameStage03_E():
global WordList
if WrdCount >= 10:
WordList = []
for n in range(0,10):
FileLines = open(FileSelection).read().splitlines()
RandWrd = random.choice(FileLines)
WordList.append(RandWrd)
SelectButton.destroy()
GameStage01Button.destroy()
GameStage04_E()
elif WrdCount <= 10:
tkinter.messagebox.showinfo("ERROR", " Insufficient Amount Of Words Within Your Text File! ")
Phone1.jsp的片段:
@RequestMapping(value="/cart.html", method = RequestMethod.POST)
public ModelAndView addToCart(@RequestParam String selectedPhone, Phone phone, DBConnection db) throws ClassNotFoundException{
String selectiPhone = "?selectedPhone=Phone1";
if (selectedPhone.equals(selectiPhone))
{
db.Query("INSERT INTO `onlineshop`.`cart` (`name`, `company`, `type`, `price`) VALUES ('"
+ phone.getName1() + "', '"+phone.getCompany1()+"', '" + phone.getType() + "', '"
+ phone.getPrice1() +"')");
}
ModelAndView cart = new ModelAndView("Cart");
return cart;
}
答案 0 :(得分:1)
selectedPhone
仅包含“Phone1”,而不是?和参数名称。
if ("Phone1".equals(selectedPhone)) {
应该为你做得更好。
祝你好运。但我不知道电话和DBConnection的价值是如何以及是否会影响您的方法......