本人新手想做个对话输入提交的网页
javabean类:
package tags;public class SubBean {
private String content = "";
public String getcontent(){
return content;
}
public void setcontent(String content){
this.content = content;
}
}
JSP部分:
<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>输入提交</title>
</head>
<body>
<h1>请输入要提交的内容</h1>
<form name="forml"method="post"action="">
<input type="text"name="String">
<input type="submit"name="submit"value="提交">
</form>
<jsp:useBean id="Sub"class="tags.SubBean"/>
<jsp:setProperty name="Sub"property="name"param="name"/>
<P>content:<jsp:getProperty name="Sub"property="name"/></P>
</body>
</html>
不知道哪出错了 望各位路过的大哥大姐指点一二···

解决方案 »

  1.   

    <form name="forml"method="post"action="">action为什么是空的?
      

  2.   

    <form name="forml"method="post"action="">
    你没有写提交给谁,一般提交给servlet进行处理 servlet要在web.xml中配置
      

  3.   

    我是参造这个例子来的
    package myBean;public class EmployeeBean {
    private int id = 0,salary = 0;
    private String name = "none",occupation = "none";
    boolean male = true;
    public int getId(){
    return id;
    }
    public void setId(int id){
    this.id = id;
    }
    public String getName(){
    return name;
    }
    public void setName(String name){
    this.name = name;
    }
    public boolean isMale(){
    return male;
    }
    public void setMale(boolean male){
    this.male = male;
    }
    public int getSalary(){
    return salary;
    }
    public void setSalary(int salary){
    this.salary = salary;
    }
    public String getOccupation(){
    return occupation;
    }
    public void setOccupation(String occupation){
    this.occupation = occupation;
    }
    }<%@page contentType="text/html;charest=gb2312" %>
    <html>
    <head>
    <title>javaBean</title>
    </head>
    <body>
    <form name="form1"method="post"action="">
    <br>name:<input type="text"name="name">
    <br>sex:<input type="radio"name="male"value="true">man
    <input type="radio"name="male"value="false">woman
    <br>id:<input type="text"name="id">
    <br>occupation:<input type="text"name="occupation">
    <br>salary:<input type="text"name="salary">
    <br><input type="submit"name="submit"value="Submit">
    </form><jsp:useBean id="employee"class="myBean.EmployeeBean"/>
    <jsp:setProperty name="employee"property="name"param="name"/>
    <jsp:setProperty name="employee"property="id"param="id"/>
    <jsp:setProperty name="employee"property="male"param="male"/>
    <jsp:setProperty name="employee"property="salary"param="salary"/>
    <jsp:setProperty name="employee"property="occupation"param="occupation"/>
    <P>name:<jsp:getProperty name="employee"property="name"/></P>
    <p>id:<jsp:getProperty name="employee"property="id"/></p>
    <p>isMale:<jsp:getProperty name="employee"property="male"/></p>
    <p>salary:<jsp:getProperty name="employee"property="salary"/>yuan</p>
    <p>occupation:<jsp:getProperty name="employee"property="occupation"/></p>
    </body>
    </html>为什么这里可以提交 我的代码就不行呢?
      

  4.   

    action=""的时候是表示提交到本页面吧~~
      

  5.   

    JSP部分改了:
    <%@ page contentType="text/html;charset=gb2312" %>
    <html>
    <head>
    <title>输入提交</title>
    </head>
    <body>
    <h1>请输入要提交的内容</h1>
    <form name="forml"method="post"action="">
    <input type="text"name="String">
    <input type="submit"name="submit"value="提交">
    </form>
    <jsp:useBean id="Sub"class="tags.SubBean"/>
    <jsp:setProperty name="Sub"property="content"param="content"/>
    <P>content:<jsp:getProperty name="Sub"property="content"/></P>
    </body>
    </html>