谢谢提示
但是我现在改了还是不行帮忙在看看代码错误信息如下
JSP页面:
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
-//W3C//DTDHTML4.01Transitional//EN”>
“>
提出技术难点
姓名:
技术难点:
serv类:
1.
packagecom.yourcompany.serv;
publicclassAdvrub{
privateintid;
privateStringusername;
privateStringcontene;
publicintgetId(){
returnid;
}
publicvoidsetId(intid){
this.id=id;
}
publicStringgetUsername(){
returnusername;
}
publicvoidsetUsername(Stringusername){
this.username=username;
}
publicStringgetContene(){
returncontene;
}
publicvoidsetContene(Stringcontene){
this.contene=contene;
}
}
2.
packagecom.yourcompany.serv;
importjava.sql.Connection;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
importjavax.naming.InitialContext;
importjavax.naming.NamingException;
importjavax.sql.DataSource;
publicclassAdvrubManager{
publicintadvrub(Stringusername,Stringcontent)throwsSQLException{
//得到数据源
DataSourceds=null;
try{
InitialContextctx;
ctx=newInitialContext();
ds=(DataSource)ctx.lookup(”java:/comp/env/jdbc/pgsql”);
}catch(NamingExceptione){
e.printStackTrace();
}
intmaxId=0;
Connectionconn=ds.getConnection();
Statementstmt=conn.createStatement();
ResultSetrs=stmt.executeQuery(”selectmax(id)fromadvrub”);
if(rs.next())
maxId=rs.getInt(1);
maxId++;
StringBuffersb=newStringBuffer();
sb.append(”insertintoadvrubvalues(”);
sb.append(maxId);
sb.append(”,'”);
sb.append(username);
sb.append(”‘,'”);
sb.append(content);
sb.append(”‘)”);
//运行insert语句,插入表中一条记录,rtn将返回1
intrtn=stmt.executeUpdate(sb.toString());
if(rtn==1)//插入数据成功
returnmaxId;
else//插入数据失败
return-1;
}
}
action:
packagecom.yourcompany.struts.action;
importjava.sql.SQLException;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importorg.apache.struts.action.ActionForm;
importorg.apache.struts.action.ActionForward;
importorg.apache.struts.action.ActionMapping;
importorg.apache.struts.actions.MappingDispatchAction;
importcom.yourcompany.struts.form.AdvrubForm;
importcom.yourcompany.serv.AdvrubManager;
importcom.yourcompany.serv.Advrub;
publicclassAdvrubActionextendsMappingDispatchAction{
publicActionForwardadvrub(ActionMappingmapping,ActionFormform,
HttpServletRequestrequest,HttpServletResponseresponse)throwsSQLException{
AdvrubFormsf=(AdvrubForm)form;
AdvrubManagersm=newAdvrubManager();
sm.advrub(sf.getUsername(),sf.getContten());
returnmapping.findForward(”success”);
}
}
form:
packagecom.yourcompany.struts.form;
importjavax.servlet.http.HttpServletRequest;
importorg.apache.struts.action.ActionErrors;
importorg.apache.struts.action.ActionMapping;
publicclassAdvrubFormextendsActionForm{
privateintid;
privateStringusername;
privateStringcontent;
publicintgetId(){
returnid;
}
publicvoidsetId(intid){
this.id=id;
}
publicStringgetUsername(){
returnusername;
}
publicvoidsetUsername(Stringusername){
this.username=username;
}
publicStringgetContten(){
returncontent;
}
publicvoidsetContent(Stringcontene){
this.content=content;
}
}
错误信息:
2007-10-2414:20:30org.apache.struts.util.RequestUtilscreateActionForm
警告:NoFormBeanConfigfoundunder’AdvrubForm’
2007-10-2414:20:30org.apache.struts.action.RequestProcessorprocessException
警告:UnhandledExceptionthrown:classjava.lang.NullPointerException
2007-10-2414:20:30org.apache.catalina.core.StandardWrapperValveinvoke
严重:Servlet.service()forservletactionthrewexception
java.lang.NullPointerException
atcom.yourcompany.struts.action.AdvrubAction.Advrub(AdvrubAction.java:31)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
atjava.lang.reflect.Method.invoke(Method.java:585)
atorg.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
atorg.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
atorg.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:169)
atorg.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
atorg.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
atorg.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
atorg.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
atjavax.servlet.http.HttpServlet.service(HttpServlet.java:710)
atjavax.servlet.http.HttpServlet.service(HttpServlet.java:803)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
atjava.lang.Thread.run(Thread.java:595)
文章来源于互联网
抑郁症的主要症状包括沮丧、悲观、忧郁等,患者自己感觉像掉进一个深不见底的深渊里一样,经常感觉到压抑、无望,没有高兴的事情,总是开心不起来,就连过去很喜欢的爱好也都提不起精神继续。和家人、朋友都开始疏远,不愿意接触人。有的患者办事开始出现犹豫不决,比如,平时换衣…