还是包错,原代码也贴出来了,怎么办。望批复。(50分)

  • 主题发起人 主题发起人 xiaotianwangzi
  • 开始时间 开始时间
X

xiaotianwangzi

Unregistered / Unconfirmed
GUEST, unregistred user!
数据库中凡是用formatToMoney插入的都是numberic类型。

<%@page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.sql.*" %>
<%@page import="java.util.*" %>
<%@page import="java.text.*" %>
<jsp:useBean id="hyg" scope="page" class="hyg.faq" />
<jsp:useBean id="money" scope="page" class="hyg.FormatMoney" />
<HTML>
<HEAD><font size=6 align="center"><h1 align="center">职工工资设定</h1></font>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=GB2312">
</head>
<body bgcolor="#ccccff" width="40%">
<%!
public String getStr(String str)
{
try
{ String temp_p=str;
byte[] tmpbyte;
tmpbyte=temp_p.getBytes("ISO8859_1");
temp_p=new String(tmpbyte);


return temp_p;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
%>
<%
int flag=0;
String bmbh=new String();
String bmmc=new String();
String xh=new String();
String zgbh=new String();
String zgxm=new String();
String zbsj=new String();
String zbnf=new String();
String zbyf=new String();
String gwlb=new String();
String zgjt=new String();
String zgyb=new String();
String sbjj=new String();
String yljj=new String();
String yhjb=new String();
String sfje=new String();
String yfje=new String();
String sql=new String();
java.text.SimpleDateFormat SDateFormater = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date d = new java.util.Date();
DateFormat defaultFormat = DateFormat.getDateTimeInstance();
DateFormat shortFormat = DateFormat.getDateTimeInstance (DateFormat.SHORT,DateFormat.SHORT);
DateFormat mediumFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
DateFormat longFormat = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG);
DateFormat fullFormat = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL);
String defaultDate = defaultFormat.format(d);
String shortDate = shortFormat.format(d);
String mediumDate = mediumFormat.format(d);
String longDate = longFormat.format(d);
String fullDate = fullFormat.format(d);
bmbh=request.getParameter("bmbh");
bmmc=request.getParameter("bmmc");
xh=request.getParameter("xh");
zgbh=request.getParameter("zgbh");
zgxm=request.getParameter("zgxm");
zbsj=request.getParameter("zbsj");
zbnf=request.getParameter("zbnf");
zbyf=request.getParameter("zbyf");
gwlb=request.getParameter("gwlb");
zgjt=request.getParameter("zgjt");
zgyb=request.getParameter("zgyb");
sbjj=request.getParameter("sbjj");
yljj=request.getParameter("yljj");
yhjb=request.getParameter("yhjb");
sfje=request.getParameter("sfje");
yfje=request.getParameter("yfje");
do
uble zgjt1 =do
uble.parseDouble(zgjt);
do
uble zgyb1 =do
uble.parseDouble(zgyb);
do
uble sbjj1 =do
uble.parseDouble(sbjj);
do
uble yljj1 =do
uble.parseDouble(yljj);
do
uble yhjb1 =do
uble.parseDouble(yhjb);
do
uble sfje1 =do
uble.parseDouble(sfje);
do
uble yfje1 =do
uble.parseDouble(yfje);


String sql2=new String();
%><%
if((bmbh.length()!=0)&amp;&amp;(xh.length()!=0)){
sql2="insert into rs_ygzls(bmbh,bmmc,xh,zgbh,xm,zbsj,zbnf,zbyf,gwlb,ryjt,zgyb,sbjj,yljj,jb,sfje,yfje)values('"+bmbh+"','"+bmmc+"','"+xh+"','"+zgbh+"','"+zgxm+"','"+zbsj+"','"+zbnf+"','"+zbyf+"','"+gwlb+"','"+money.formatToMoney(zgjt)+"','"+money.formatToMoney(zgyb1)+"','"+money.formatToMoney(sbjj1)+"','"+money.formatToMoney(yljj1)+"','"+money.formatToMoney(yhjb1)+"','"+money.formatToMoney(sfje1)+"','"+money.formatToMoney(yfje1)+"')";
//sql="update cd_user_info set user_password='"+mi1+"'where user_password='"+mima+"'and user_name='"+xingm1+"'";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=rj;DatabaseName=mjgl001");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql2);


// ResultSet rs=hhh.executeQuery(sql);
%><div align="center">
<h3><font align="center">你好,工资设置成功</font></h3>
<br>
<br><a href="jxglxt.html">返回首页</a>
</div>
<%
}
else
{
%>
<div align="center">
<h3><font align="center">对不起,请检查输入项,请重新输入。</font></h3>
<br>
<font align="center"><a href="mmxg1.jsp">返回</a></font>
</div>
<%
}
%>
</body>
</html>

报错如下:
java.lang.NumberFormatException: ?÷??
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1213)
at java.lang.Double.parseDouble(Double.java:201)
at org.apache.jsp.gzsz$jsp._jspService(gzsz$jsp.java:209)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.authen
ticator.Authen
ticatorBase.invoke(Authen
ticatorBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:536)
 
你可以
try 一下 看看
还把你的要插入数据库的值 out出来看看 有没有什么问题,把下面对数据库的 操作的语句先屏蔽掉
 
它不是提示parseDouble出错了么,你调试调试,可以先看看用到parseDouble的地方的数据是什么。
 
嗯?怎么没有反馈?
 
现在我已经解决了这个问题,能够实现了,还有就是如何控制的问题。
 
如何控制!我先猜猜你想要控制什么……
 
不好意思,说的不清楚。
1 在i不为0时执行下面的语句,如果为0,显示“检查输入项,请重新填写”
2 flag控制是这样的,如果flag为1 表示数据库中没有此条记录,添加,否则,已经哟次记录,不能添加。
 
我眼睛都看花了,也没有找到你说的 i;
flag 还好,能找到定义,不过编译器优化的话一定把它忽略掉。
 
或许我误解了。要的是这些东西吗?
<%
/** 在i不为0时执行下面的语句,如果为0,显示“检查输入项,请重新填写”*/
if (i == 0){
out.print("检查输入项,请重新填写");
return;
}
/** */
if (flag == 1){
// insertRecord();
} else
{
out.print("记录已经存在!");
}
%>
 
原代码帖出来了
<%@page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.sql.*" %>
<%@page import="java.util.*" %>
<%@page import="java.text.*" %>
<jsp:useBean id="hyg" scope="page" class="hyg.faq" />
<jsp:useBean id="money" scope="page" class="hyg.FormatMoney" />
<jsp:useBean id="calendar" scope="page" class="hyg.JspCalendar"/>
<HTML>
<HEAD><font size=6 align="center"><h1 align="center">职工工资设定</h1></font>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=GB2312">
</head>
<body bgcolor="#ccccff" width="40%">
<%!
public String getStr(String str)
{
try
{ String temp_p=str;
byte[] tmpbyte;
tmpbyte=temp_p.getBytes("GBK");
temp_p=new String(tmpbyte);


return temp_p;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
public String getStr1(String str)
{
try
{ String temp_p=str;
byte[] tmpbyte;
tmpbyte=temp_p.getBytes("ISO8859-1");
temp_p=new String(tmpbyte);


return temp_p;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
%>
<%
int i;

String bmbh=new String();
bmbh=(String)session.getValue("bmbh3");
String bmmc=new String();
bmmc=(String)session.getValue("bmmc3");
String xh=new String();
xh=(String)session.getValue("xh3");
String zgbh=new String();
String zgxm=new String();
zgxm=(String)session.getValue("zgxm3");
String zbsj=new String();
String zbnf=new String();
String zbyf=new String();
String gwlb=new String();
String zgjt=new String();
String zgyb=new String();
String sbjj=new String();
String yljj=new String();
String yhjb=new String();
String sfje=new String();
String yfje=new String();
String sql=new String();
java.text.SimpleDateFormat SDateFormater = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date d = new java.util.Date();
DateFormat defaultFormat = DateFormat.getDateTimeInstance();
DateFormat shortFormat = DateFormat.getDateTimeInstance (DateFormat.SHORT,DateFormat.SHORT);
DateFormat mediumFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
DateFormat longFormat = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG);
DateFormat fullFormat = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL);
String defaultDate = defaultFormat.format(d);
String shortDate = shortFormat.format(d);
String mediumDate = mediumFormat.format(d);
String longDate = longFormat.format(d);
String fullDate = fullFormat.format(d);

zgbh=(String)session.getValue("zgbh3");
zbsj=defaultDate;
zbnf=""+calendar.getYear();
zbyf=calendar.getMonthnum();
gwlb=(String)session.getValue("gwlb3");
zgjt=request.getParameter("zgjt");
zgyb=request.getParameter("zgyb");
sbjj=request.getParameter("sbjj");
yljj=request.getParameter("yljj");
yhjb=request.getParameter("yhjb");
sfje=request.getParameter("sfje");
do
uble zgjt1 =do
uble.parseDouble(zgjt);
do
uble zgyb1 =do
uble.parseDouble(zgyb);
do
uble sbjj1 =do
uble.parseDouble(sbjj);
do
uble yljj1 =do
uble.parseDouble(yljj);
do
uble sfje1 =do
uble.parseDouble(sfje);
do
uble yfje1 = (zgjt1+zgyb1+sbjj1+yljj1);
String zgxm1=getStr(zgxm);
//将职工姓名和部门名称进行编码,以便插入数据库。
String bmmc1=getStr(bmmc);
String yhjb1=getStr1(yhjb);
i=zgjt.length()*zgyb.length()*sbjj.length()*yljj.length()*yhjb.length()*sfje.length();
String sql2=new String();
if(i!=0){
//String ss=new String();
//ss="select * from rs_ygzxx where zgbh='"+zgbh+"'";
//ResultSet rs=hyg.executeQuery(ss);
//int flag=1;
//if(rs.next()){
// flag=0;
// }
//rs.close();
//if(flag==1){
sql2="insert into rs_ygzls(bmbh,bmmc,xh,zgbh,xm,zbsj,zbnf,zbyf,gwlb,ryjt,zgyb,sbjj,yljj,jb,sfje,yfje)values('"+bmbh+"','"+bmmc1+"','"+xh+"','"+zgbh+"','"+zgxm1+"','"+zbsj+"','"+zbnf+"','"+zbyf+"','"+gwlb+"','"+zgjt1+"','"+zgyb1+"','"+sbjj1+"','"+yljj1+"','"+yhjb1+"','"+sfje1+"','"+yfje1+"')";
sql="insert into rs_ygzxx(bmbh,bmmc,xh,zgbh,xm,zbsj,zbnf,zbyf,gwlb,ryjt,zgyb,sbjj,yljj,jb,sfje,yfje)values('"+bmbh+"','"+bmmc1+"','"+xh+"','"+zgbh+"','"+zgxm1+"','"+zbsj+"','"+zbnf+"','"+zbyf+"','"+gwlb+"','"+zgjt1+"','"+zgyb1+"','"+sbjj1+"','"+yljj1+"','"+yhjb1+"','"+sfje1+"','"+yfje1+"')";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=rj;DatabaseName=mjgl001");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql2);
stmt.executeUpdate(sql);
// ResultSet rs=hhh.executeQuery(sql);
stmt.close();
conn.close();
%>
<h3><font ><%=zgxm1%>你好,工资设置成功</font></h3>
<br>
<br>
<div align="center">
<table width="80%" border="1" align="center" cellspacing="0" cellpadding="0">
<tr><td>部门编号:</td><td><%=bmbh%>
<td>部门名称:</td><td><%=bmmc1%></tr>
<tr><td>序号:</td><td><%=xh%>
<td>职工姓名:</td><td><%=zgxm1%></tr>
<tr><td>用户级别:</td><td><%=yhjb1%>
<td>岗位类别:</td><td><%=gwlb%></tr>
<tr><td>职工津贴:</td><td><%=zgjt1%>
<td>职工月补:</td><td><%=zgyb1%></tr>
<tr><td>社保基金:</td><td><%=sbjj1%>
<td>医疗基金:</td><td><%=yljj%></tr>
<tr><td>应发金额:</td><td><%=yfje1%>
<td>实发金额:</td><td><%=sfje1%></tr>
</table>
<p>
如果设置完成,请<a href="jxglxt.html">返回首页</a>
<br><a href="yggz.html">继续设置</a>
</div>
<%
//}
//else
{
%>

<font align="center"><a href="mmxg1.jsp">返回</a></font>
<%
//}
}else
{
%>
<b>请检查是否有未填项</b>
<%
}
%>
</body>
</html>
 
有什么问题出现?
 
多人接受答案了。
 
后退
顶部