当然是报错了,因为request没有定义啊用servlet一般要重写doGet(HttpServletRequest request,HttpServletResponse response) 或doPost(HttpservletRequest request,HttpServletResponse response)
然后服务器会根据具体的情况调用相应的方法。你的意思的可能是以下的。
public class FormRequest extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
NewsVo var=addrequest(request);}
public NewsVo addrequest(HttpServletRequest request) {
WYTools tool = new WYTools();
NewsVo news = new NewsVo();
String title = (String) tool.nvlStr((request.getParameter("title")));
String titlecolor = (String) tool.nvlStr((request.getParameter(
"titlecolor")));
String content = (String) tool.nvlStr((request.getParameter("content"))); news.setContent(content);
news.setTitle(title);
news.setTitlecolor(titlecolor);
return news;
}
然后服务器会根据具体的情况调用相应的方法。你的意思的可能是以下的。
public class FormRequest extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
NewsVo var=addrequest(request);}
public NewsVo addrequest(HttpServletRequest request) {
WYTools tool = new WYTools();
NewsVo news = new NewsVo();
String title = (String) tool.nvlStr((request.getParameter("title")));
String titlecolor = (String) tool.nvlStr((request.getParameter(
"titlecolor")));
String content = (String) tool.nvlStr((request.getParameter("content"))); news.setContent(content);
news.setTitle(title);
news.setTitlecolor(titlecolor);
return news;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货