一个JSTL添加添据的问题。
<sql:update var= "update1 " dataSource= "${DateConnection} ">
insert into newsclass(classname,orderid) values(?,?)
<sql:param value= " <%=trans(newsclass.getClassname())%> "/>
<sql:param value= "55 "/> //设为数字正常运行,可以添加到数据库
</sql:update>
<c:url value= "index.jsp " var= "jurl "> </c:url>
<c:redirect url= "${jurl} "/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
单独获取值: <%=newsclass.getOrderid()%> ,动态输入20,是正常的。
<sql:update var= "update1 " dataSource= "${DateConnection} ">
insert into newsclass(classname,orderid) values(?,?)
<sql:param value= " <%=trans(newsclass.getClassname())%> "/>
<sql:param value= " <%=newsclass.getOrderid()%> "/> //用获取的表量变量出错。
</sql:update>
<c:url value= "index.jsp " var= "jurl "> </c:url>
<c:redirect url= "${jurl} "/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
出错提示,那位兄弟帮忙看下是什么原因:
数据表:newsclass
nid int 自动编号
classname varchar(50)
order int
^^^^^^^^^^^^^^^^^^^
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 21 in the jsp file: /NewsClass/add.jsp
Generated servlet error:
C:\Tomcat\work\Catalina\localhost\java\org\apache\jsp\NewsClass\add_jsp.java:190: cannot resolve symbol
symbol : method setValue (int)
location: class org.apache.taglibs.standard.tag.rt.sql.ParamTag
_jspx_th_sql_param_1.setValue(newsclass.getOrderid());
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
------解决方案-------------------- <sql:param value= " <%=newsclass.getOrderid()%> "/> //用获取的表量变量出错。
改成
<sql:param value= " <%= "newsclass.getOrderid() "%> "/>
即 <%=%> 中加入 " "
我的异常网推荐解决方案:
tomcat没法解析jsp文件