回 帖 发 新 帖 刷新版面

主题:jsp中使用javaBean时的问题

在jsp中调用javaBean时,是不是一定得配置web.xml文件?里面的内容要根据什么来写啊?我注册的内容提交不了,提交目的文件代码如下:
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page language="java" import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<html>
    <head>
        <title>注册确认 </title>
    </head>
    <body>
        <jsp:useBean id="bidBean" scope="page" class="firm.firm"/>
        <%
      String name1=new String(request.getParameter("user_id").getBytes("8859-1"));
      String password=request.getParameter("password");
      String email=request.getParameter("email");
      String qq=request.getParameter("QQ");
      String domID=request.getParameter("domID");
      String sql="select * from user where name='"+name1+"'";
      ResultSet rs=bidBean.executeQuery(sql);
      if(rs.next())
      {
        rs.close();
        session.putValue("register_message","该会员已经存在,请重新输入!");
      %>
      <jsp:forward page="register.jsp"/>
      <%
      }
    else
    {
      rs.close();
    }
    %>
    <form method=post action="ok_register.jsp">
        <input type="hidden" name="user_id" value="<%=name1%>">
        <input type="hidden" name="password" value="<%=password%>">
        <input type="hidden" name="email" value="<%=email%>">
        <input type="hidden" name="qq" value="<%=qq%>">
        <input type="hidden" name="domID" value="<%=domID%>>
        <font color="red"><%=name1%>您好,请检查您的注册信息是否正确!</font><br><br>
        <table border="1" cellspacing="0" width="332" bgcolor="#f0f8ff" bordercolorlight="#4da6ff"
                 bordercolordark="#ecf5ff">
            <tr>
                <td>登录名:</td>
                <td><%=name1%></td>
            </tr>
            <tr>
                <td>密码:</td>
                <td><%=password%></td>
            </tr>
            <tr>
                <td>E-mail:</td>
                <td><%=email%></td>
            </tr>
            <tr>
                <td>QQ:</td>
                <td><%=qq%></td>
            </tr>
            <tr>
                <td>宿舍号:</td>
                <td><%=domID%></td>
            </tr>
        </table>
        <br>
        <input name="submit" type="submit" class="buttonface" value="提交">&nbsp;&nbsp;
        <input type="button" name="button" class="buttonface" onclick="history.back()" value="修改">
    </form>
  </body>
</html>
          
      
在注册页面点击提交按钮后就会出现如下东西:
java.io.UnsupportedEncodingException: 8859-1
    sun.io.Converters.getConverterClass(Converters.java:218)
    sun.io.Converters.newConverter(Converters.java:251)
    sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:68)
    java.lang.StringCoding.encode(StringCoding.java:374)
    java.lang.String.getBytes(String.java:812)
    org.apache.jsp.register_005fconfirm_jsp._jspService(register_005fconfirm_jsp.java:66)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  小弟是初学者,看不懂是什么,请大家帮忙指点一下!!

回复列表 (共1个回复)

沙发

String name1=new String(request.getParameter("user_id").getBytes("8859-1"));

这句改变以下  “ISO-8859-1” 解码的名称不对引起的错误

我来回复

您尚未登录,请登录后再回复。点此登录或注册