***Add
If you insert, it becomes a part and there are values that go to the null value.
Table:
CREATE TABLE goods(
rnum INT AUTO_INCREMENT PRIMARY KEY,
deal_code VARCHAR(15) ,
category_code VARCHAR(15) ,
goods_name VARCHAR(30) ,
price INT,
sell_start DATE ,
sell_end DATE ,
goal_num INT,
content VARCHAR(4000),
summary VARCHAR(300) ,
sell_num INT ,
success_tf VARCHAR(15),
id VARCHAR(15),
image VARCHAR(4000));
Goods.xml :
<mapper namespace="kr.or.connect.mybatis.goods">
<resultMap type="Goods" id="goodsResult">
<result property="rnum" column="rnum"/>
<result property="dealCode" column="DEAL_CODE"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="goodsName" column="GOODS_NAME"/>
<result property="price" column="PRICE"/>
<result property="sellStart" column="SELL_START"/>
<result property="sellEnd" column="SELL_END"/>
<result property="goalNum" column="GOAL_NUM"/>
<result property="content" column="CONTENT"/>
<result property="summary" column="SUMMARY"/>
<result property="sellNum" column="SELL_NUM"/>
<result property="successTf" column="SUCCESSTF"/>
<result property="id" column="ID"/>
<result property="image" column="IMAGE"/>
</resultMap>
<insert id="insert" parameterType="GOODS">
INSERT into goods values (#{rnum}, #{dealCode}, #{categoryCode}, #{goodsName}, #{price}, NOW(), #{sellEnd}, #{goalNum}, #{content}, #{summary}, #{sellNum}, #{image}, #{successTf}, #{id});
</insert>
dto (I also made a get, set):
private int rnum;
private String dealCode; // f.k
private String categoryCode; // f.k
private String goodsName;
private int price;
private Date sellStart;
private Date sellEnd;
private int goalNum;
private String content;
private String summary;
private int sellNum;
private String successTf;
private String id; // f.k
private String image;
dao :
@Repository("GoodsDao")
public class GoodsDaoImpl implements GoodsDao{
@Autowired
private SqlSessionTemplate sqlSession;
private String ns = "kr.or.connect.mybatis.goods";
@Override
public void insert(Goods goods) {
sqlSession.insert(ns+".insert", goods);
}
}
service :
@Override
public void insert(Goods goods) {
goodsDao.insert(goods);
}
controller :
@PostMapping(path="/portfolio")
public String create(@ModelAttribute Goods goods,
HttpServletRequest request) {
goodsService.insert(goods);
return "portfolio";
}
jsp:
input type="text" id="title" name="goodsName" placeholder="product name"
style="border-width:0px 0px 5px 0px; border-color : #8C8C8C;
width:650px; height: 45px; font-size: 20pt; color: #8C8C8C;"/>
textarea id="summary" name="summary" placeholder="Please enter a brief introduction" style="height: 130px; width:430px;"></textarea></td>
textarea id="summernote" name="content"></textarea>
// These three are input.
input type="date" class="form-control" name="sellEnd">
input name = "goalNum" value='' id="goalNum" type="number" class="form-control" />
// These two do not insert.
Since db is date and HTml is also date, don't you need a separate conversion process?
I tried to change the input values to text, but I couldn't get the text.
If you know, please leave a comment<
I will add more if there is not enough explanation.
Looks like a form with a file upload In that case, make sure to use the form tag as follows.
<formaction="blah blah" method="post" type="multipart/form-data">
After doing this, please check with the developer tool how to transfer Form Data again. I think the file upload itself is also failing in the first place.
© 2024 OneMinuteCode. All rights reserved.