当前位置: 代码迷 >> Java Web开发 >> Cannot find any information on property 'cipher' in a bean of type 'xx.JiamiBean解决思路
  详细解决方案

Cannot find any information on property 'cipher' in a bean of type 'xx.JiamiBean解决思路

热度:4525   发布时间:2013-02-25 21:17:23.0
Cannot find any information on property 'cipher' in a bean of type 'xx.JiamiBean
准备写一个MVC架构的小程序,实现的目标是在Face.jsp中输入一串字符,然后在showMiwen.jsp中会把加密后的密文给输出来,结果抛出了org.apache.jasper.JasperException: Cannot find any information on property 'ciphertext' in a bean of type 'xx.JiamiBean'这种异常,希望大家能够帮忙解决一下,先贴代码吧:
这是javaBean文件
package xx;

public class JiamiBean {
private String cleartext;

private char[] letter = {'A','B','C','D','E','F','G','H','I','G','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
private int[] wheel1={23,24,25,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22};
private int[] wheel2={7,17,25,16,19,21,9,2,12,10,3,22,4,23,8,11,24,15,18,5,14,20,1,6,0,13};
String ciphertext2 ;
char[] chararr;
private String ciphertext;
public JiamiBean(){}
public JiamiBean(String cleartext){
this.ciphertext=encrypt(cleartext);
}
public String getcleartext() {
return this.cleartext;
}
public void setcleartext(String cleartext) {
this.cleartext = cleartext;
}
private void setciphertext(String ciphertext){
this.ciphertext=ciphertext;
}
private String getciphertext(){
return this.ciphertext;
}

public String encrypt(String str){

chararr=str.toCharArray();
int cl=chararr.length;
char[] mw=new char[cl];

try {

for(int i=0;i<cl;i++){
int j=wheel1[i];
int k=wheel2[j];
mw[i]=letter[k];
}
ciphertext2=arrToString(mw);


} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage()+"encrypt");
}
System.out.println(ciphertext2);
return ciphertext2;
}

static String arrToString(char[] arr){
StringBuilder jbs=new StringBuilder();
for(char x:arr){
jbs.append(x);
}
return jbs.toString();
}

}

这是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 doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

request.setCharacterEncoding("gb2312");
response.setContentType("text/html;charset=gb2312");
String cleartext=request.getParameter("cleartext");
System.out.println(cleartext);
JiamiBean jb=new JiamiBean(cleartext);

request.setAttribute("JiamiBean", jb);
RequestDispatcher rd=request.getRequestDispatcher("showMiwen.jsp");
rd.forward(request, response);
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
}

这是登陆界面
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>Cleartext</title>
   
<meta http-equiv="pragma" content="no-cache">
  相关解决方案