插入数据失败

public class Clothes extends BaseClothes<Clothes> {
	public static final Clothes me = new Clothes().dao();
	public Page<Clothes> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from clothes order by id asc");
	}
}
<---------------------------------->
protected void handleError(Controller controller) {
		controller.keepModel(Clothes.class);
		
		String actionKey = getActionKey();
		if (actionKey.equals("/clothes/save"))
			controller.render("add.html");
		else if (actionKey.equals("/clothes/update"))
			controller.render("edit.html");
	}
	
<------------add.html--------->
#@layout()
#define main()
<h1>clothes管理 ---&gt; 新增产品
</h1>
<div class="form_box">
<form action="/clothes/save" method="post">
#include("_form.html")
</form>
</div>
#end

<----------------_form.html-------------->
<fieldset class="solid">
	<legend>新增产品</legend>
	<input type="hidden" name="clothes.id" value="#(clothes.id??)" />
	<div>
		<label>产品编号</label>
		<input type="text" name="clothes.clothesNum" value="#(clothes.clothesNum??)" />#(clothesNumMsg)
	</div>
	<div>
		<label>零售价</label>
		<input type="text" name="clothes.retailPrise" value="#(clothes.retailPrise??)" />#(retailPriseMsg)
	</div>
	<div>
		<label>&nbsp;</label>
		<input value="提交" type="submit">
	</div>
</fieldset>

<-----------------ClothesController----------------->
public class ClothesController extends Controller {
public void index() {
		setAttr("clothesPage", Clothes.me.paginate(getParaToInt(0, 1), 10));
		render("clothes.html");
	}
//保存
	@Before(ClothesValidator.class)
	public void save() {
		getModel(Clothes.class).save();
		redirect("/clothes");
	}
}
<------------------------------>
	

点击提交按钮("submit")后,数据没有插入到数据库,页面也没有自动跳转,请问submit后是哪里出了问题?

1.PNG

评论区

Irin.Chan

2017-04-02 15:31

打个断点跟一下

tobecontinue

2017-04-02 16:17

发现public void save() {
getModel(Clothes.class).save();
redirect("/clothes");
}
这段代码是没有被执行的,怪不得提交不了,不过为什么没被执行呢。。。

tobecontinue

2017-04-02 17:02

//保存
@Before(ClothesValidator.class)
public void save() {
System.out.println("ClothesController save1");
getModel(Clothes.class).save();
System.out.println("ClothesController save2");
redirect("/clothes");
System.out.println("ClothesController save3");
}
控制台:
Before invoking /clothes/save
After invoking /clothes/save

JFinal action report -------- 2017-04-02 16:14:48 ------------------------------
Url : POST /clothes/save
Controller : com.demo.clothes.ClothesController.(ClothesController.java:1)
Method : save
Interceptor : com.demo.clothes.ClothesInterceptor.(ClothesInterceptor.java:1)
com.demo.clothes.ClothesValidator.(ClothesValidator.java:1)
Parameter : clothes.pattern=6 clothes.clothesNum=6 。。。。。。
本来应该有printed出来ClothesController save123的,为什么没有?

tobecontinue

2017-04-02 17:17

@Irin.Chan 是public void save()没被执行,请问这是怎么回事呢?

tobecontinue

2017-04-02 18:28

已解决,是我的表少了一个字段QAQ