我不得不通過Struts2的使用EJB到我的圖像存儲到數據庫的Oracle。它堅持的數據,但是當我添加輸入文件JSP我的NullPointerException在這條線:專賣店形象到數據庫中使用的Struts2和EJB
byte[] buffer=new byte[(int)this.telethoraxImg.length()];
下面是我的一些代碼部分:
PictureAction.java
public class PictureAction extends ActionSupport implements SessionAware{
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(MorphoRECAction.class);
private Map session ;
private ExamMorpho exMoR;
private Patient pat;
private HttpServletRequest request;
public void setServletRequest(HttpServletRequest request) {
this.request=request;
}
public ExamMorpho getExam(){
return exMoR;
}
public void setExam(ExamMorpho exMoR){
this.exMoR = exMoR;
}
public Patient getPat(){
return pat;
}
public void setPat(Patient pat){
this.pat = pat;
}
private Date dateExMorpho;
private String echoAbdo;
private String echoCard;
private String exGyneco;
private String exOphtalmo;
private String mamo;
private String telethoraxTxt;
private File telethoraxImg;
public String execute(){
log.info("Entrée dans la méthode execute() ");
System.out.println("creation examen");
ExamMorpho ex = new ExamMorpho();
System.out.println("fin création");
try{
Patient pt = (Patient)session.get("lepat");
InitialContext initialContext = new InitialContext();
ExMorphoRemote facade = (ExMorphoRemote) initialContext.lookup("PatProjet/ExMorphoBean/remote");
System.out.println("ID Patient RECUPERE /" + pt.getIdPat());
System.out.println("Debut conversion image");
byte[] buffer=new byte[(int)this.telethoraxImg.length()];
/*exMoR = new ExamMorpho(buffer, dateExMorpho, echoAbdo, echoCard, exGyneco, exOphtalmo, mamo, telethoraxTxt); */
System.out.println("Fin conversion image");
FileInputStream in=new FileInputStream(this.telethoraxImg);
in.read(buffer);
ex.setTelethoraxImg(buffer);
ex.setDateExMorpho(dateExMorpho);
ex.setEchoAbdo(echoAbdo);
ex.setEchoCard(echoCard);
ex.setExGyneco(exGyneco);
ex.setExOphtalmo(exOphtalmo);
ex.setMamo(mamo);
ex.setTelethoraxTxt(telethoraxTxt);
System.out.println("FIN AJOUT IMAAAGE");
exMoR = facade.AddExMorphoR(ex, pt);
System.out.println("FIN AJOUT MORPHOOS");
} catch(Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
/*private byte[] telethoraxImg = null;
public byte[] getTelethoraxImg() {
return this.telethoraxImg;
}
public void setTelethoraxImg(byte[] telethoraxImg) {
System.out.println("ENTREE ADD IMAGE");
this.telethoraxImg = telethoraxImg;
System.out.println("SORTIE ADD IMAGE");
}*/
/*private Date dateExMorpho = null;
public Date getDateExMorpho() {
return this.dateExMorpho;
}
public void setDateExMorpho(Date dateExMorpho) {
this.dateExMorpho = dateExMorpho;
}
private String echoAbdo = null;
public String getEchoAbdo() {
return this.echoAbdo;
}
public void setEchoAbdo(String echoAbdo) {
this.echoAbdo = echoAbdo;
}
private String echoCard = null;
public String getEchoCard() {
return this.echoCard;
}
public void setEchoCard(String echoCard) {
this.echoCard = echoCard;
}
private String exGyneco = null;
public String getExGyneco() {
return this.exGyneco;
}
public void setExGyneco(String exGyneco) {
this.exGyneco = exGyneco;
}
private String exOphtalmo = null;
public String getExOphtalmo() {
return this.exOphtalmo;
}
public void setExOphtalmo(String exOphtalmo) {
this.exOphtalmo = exOphtalmo;
}
private String mamo = null;
public String getMamo() {
return this.mamo;
}
public void setMamo(String mamo) {
this.mamo = mamo;
}
private String telethoraxTxt = null;
public String getTelethoraxTxt() {
return this.telethoraxTxt;
}
public void setTelethoraxTxt(String telethoraxTxt) {
this.telethoraxTxt = telethoraxTxt;
}
*/
public void setSession(Map session) {
this.session = session;
}
public Map getSession() {
return session;
}
}
向我們展示了JSP代碼... – goodyzain
註釋掉的getter/setter方法'telethoraxImg'。 –
我會嘗試感謝你希望它會工作 – Sissi