日期:2014-05-17  浏览次数:20750 次

一个关于javaBean+servlet+jsp的MVC架构问题
//jsp的代码:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="xx.JiamiBean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title>密文</title>
  </head>
  <body>
  <jsp:useBean id="JMBean" class="xx.JiamiBean" scope="request">
  <table align="center">
  <h4>密文</h4>
  <tr>
<td><textarea><jsp:getPropertyname="JMBean"property="mingwen" ></jsp:getProperty></textarea></td>
  </tr>
  </table>
  </jsp:useBean>
  </body>
</html>
//JavaBean代码
package xx;

public class JiamiBean {
private String mingwen;
//private String key="";
public JiamiBean(){}
public JiamiBean(String mingwen){
this.mingwen=mingwen;
}

public void setMingwen(String mingwen){
this.mingwen=mingwen;
}
public String getMingwen(){
return mingwen;
}
}

//servlet代码
package xx;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Jiami extends HttpServlet {
public Jiami() {
super();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);

}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
  response.setContentType("text/html;charset=gb2312");
  String mingWen=request.getParameter("mingwen");
  JiamiBean jb=new JiamiBean(mingWen);
  request.setAttribute("JiamiBean", jb);
  RequestDispatcher rd=request.getRequestDispatcher("showMiwen.jsp");
  rd.forward(request, response);
}
}
//输出的异常
2011-10-25 8:06:07 org.apache.catalina.core.ApplicationContext log
信息: Marking servlet Jiami as unavailable
2011-10-25 8:06:07 org.apache.catalina.core.ApplicationContext log
严重: Error loading WebappClassLoader
  context: /xinxi
  delegate: false
  repositories:
  /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@182bcde
 Jiami
java.lang.ClassNotFoundException: Jiami
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
org.apache