我有一个输入字段
<body>
<center>
<div style="margin-top : 1px; border:1px solid #e4e4e4; width : 500px; background: #efefef; box-shadow : 0px 0px 20px 10px #e5e5e5 inset;">
<p style="font-size: 18pt; font-family: verdana; text-shadow: 0px 0px 4px #000; color:#fff;">Student Exam Data</p>
<form onsubmit="return message()">
<p class="heading">Student Details</p>
<p class="data">
<label>Roll Number</label><input type="text" name="rollno" id="rollno" maxlength="4"/>
</p>
<p class="heading">Marks Obtained For Languages</p>
<p class="data">
<label>English</label><input type="text" name="english" id="english" onchange="calculate()" maxlength="3"/>
</p>
<p class="data">
<label>Konkani</label><input type="text" name="konkani" id="konkani" onchange="calculate() maxlength="3""/>
</p>
<p class="heading">Marks Obtained For Natural Science</p>
<p class="data">
<label>Maths</label><input type="text" name="maths" id="maths" onchange="calculate() maxlength="3""/>
</p>
<p class="data">
<label>Physics</label><input type="text" name="physics" id="physics" onchange="calculate() maxlength="3""/>
</p>
<p class="data">
<label>Chemistry</label><input type="text" name="chemistry" id="chemistry" onchange="calculate() maxlength="3""/>
</p>
<p class="heading">Marks Obtained For Social Science</p>
<p class="data">
<label>Geography</label><input type="text" name="geography" id="geography" onchange="calculate() maxlength="3""/>
</p>
<p class="heading">Total Marks Obtained</p>
<p class="data">
<label>Total Marks</label><input type="text" name="total" id="total" readonly="readonly"/>
</p>
<p class="heading">Percentage</p>
<p class="data">
<label>Percentage</label><input type="text" name="percentage" id="percentage" readonly="readonly"/>
</p>
<p>
<input type="submit" value="Submit">
</p>
<input type="hidden" name="mode" value="set">
</form>
</div>
</center>
<c:if test="${param.mode == 'set'}">
roll number<c:out value="${param.rollno}"></c:out>
<c:catch var="exception">
<sql:setDataSource var="examDatabase" password="" user="root" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/examination"/>
<sql:update var="result" sql="insert into student_examdata values(?,?,?,?,?,?,?,?,?)" dataSource="${examDatabase}">
<sql:param value="${param.rollno}.trim()"></sql:param>
<sql:param value="${param.english}.trim()"></sql:param>
<sql:param value="${param.maths}.trim()"></sql:param>
<sql:param value="${param.physics}.trim()"></sql:param>
<sql:param value="${param.chemistry}.trim()"></sql:param>
<sql:param value="${param.konkani}.trim()"></sql:param>
<sql:param value="${param.geography}.trim()"></sql:param>
<sql:param value="${param.total}.trim()"></sql:param>
<sql:param value="${param.percentage}.trim()"></sql:param>
</sql:update>
</c:catch>
<c:if test="${exception != null }">
<p class="error">
<strong style="background : #fff; color:#000; width : 300px;">Exception</strong><br><br>
<c:out value="${exception.message}"></c:out>
</p>
</c:if>
</c:if>
</body>
字段roll_no的数据类型是varchar(4)。
错误是: 插入student_examdata值(?,?,?,?,?,?,?,?,?):数据截断:第1行的列'roll_no'的数据太长
请帮忙。
答案 0 :(得分:1)
<sql:param value="${param.rollno}.trim()"></sql:param>
如果您正在尝试修剪rollno,请使用此
<sql:param value="${param.rollno.trim()}"></sql:param>
我希望能回答你的问题!