java实现网页新闻程序
*************不要问我是谁。请叫我雷锋!************
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1093 2017-04-01 11:48 news.classpath
文件 1329 2017-04-01 12:05 news.project
文件 522 2017-04-01 11:48 news.settings.jsdtscope
文件 364 2017-04-01 11:48 news.settingsorg.eclipse.jdt.core.prefs
文件 471 2017-04-01 11:48 news.settingsorg.eclipse.wst.common.component
文件 414 2017-04-01 11:48 news.settingsorg.eclipse.wst.common.project.facet.core.xml
文件 49 2017-04-01 11:48 news.settingsorg.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-04-01 11:48 news.settingsorg.eclipse.wst.jsdt.ui.superType.name
文件 4823 2018-10-25 10:41 newssrccomactionAddNewAction.java
文件 2349 2017-04-11 10:04 newssrccomactionAddTopicAction.java
文件 2217 2017-04-11 10:11 newssrccomactionDelTopicAction.java
文件 2725 2017-04-18 08:52 newssrccomactionIndexAction.java
文件 3244 2017-04-15 09:45 newssrccomactionLoginAction.java
文件 2303 2017-04-11 10:42 newssrccomactionOneTopicAction.java
文件 2902 2017-04-11 08:51 newssrccomactionTestAction.java
文件 2719 2017-04-18 08:50 newssrccomactionTopicListAction.java
文件 2533 2017-04-11 10:52 newssrccomactionUpdateTopicAction.java
文件 253 2017-04-07 09:14 newssrccomdaoimplaseDao.java
文件 981 2017-04-05 21:21 newssrccomdaoimplJdbcUtil.java
文件 4032 2017-04-15 11:06 newssrccomdaoimplTopicDao.java
文件 787 2017-04-07 09:37 newssrccomdaoimplUserDao.java
文件 353 2017-04-15 10:07 newssrccomdaoITopicDao.java
文件 151 2017-04-07 09:08 newssrccomdaoIUserDao.java
文件 2093 2017-03-06 11:42 newssrccomentityNews.java
文件 437 2017-03-06 11:42 newssrccomentityTopic.java
文件 611 2017-03-06 11:42 newssrccomentityUsers.java
文件 683 2017-04-15 09:42 newssrccomserviceimplAppUtil.java
文件 696 2017-04-15 11:12 newssrccomserviceimplTopicService.java
文件 347 2017-04-07 09:44 newssrccomserviceimplUserService.java
文件 366 2017-04-15 11:11 newssrccomserviceITopicService.java
............此处省略115个文件信息
package com.action;
import java.io.*;
import java.util.*;
import com.entity.*;
import com.service.*;
import com.service.impl.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AddNewAction extends HttpServlet {
/**
* Constructor of the object.
*/
public AddNewAction() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(request response);
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
request.setCharacterEncoding(“GBK“);
boolean ckUpload = ServletFileUpload.isMultipartContent(request);
String ntid =““;
String ntitle =““;
String nauthor =““;
String nsummary =““;
String ncontent =““;
String npicpath =““;
// request.getParameter(arg0) 不能用
if(ckUpload){
//1. 文件上传
boolean ckFile = true;//文件是否上传成功
try{
DiskFileItemFactory df = new DiskFileItemFactory();
ServletFileUpload sfu = new ServletFileUpload(df);//上传组件
String filePath = request.getServletContext().getRealPath(“upload/“);
System.out.println(“----filePath = “+filePath);
//设置上传文件的大小
//sfu.setSizeMax(sizeMax);
sfu.setFileSizeMax(500*1024*1024);
//解析请求
List flist = sfu.parseRequest(request);
for(FileItem fit : flist){
if(fit.isFormField()){ // 普通组件: textcheckboxradiopassword
//取表单元素的值
if(fit.getFieldName().equals(“ntid“)){
ntid = fit.getString(“GBK“);
}
if(fit.getF
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1093 2017-04-01 11:48 news.classpath
文件 1329 2017-04-01 12:05 news.project
文件 522 2017-04-01 11:48 news.settings.jsdtscope
文件 364 2017-04-01 11:48 news.settingsorg.eclipse.jdt.core.prefs
文件 471 2017-04-01 11:48 news.settingsorg.eclipse.wst.common.component
文件 414 2017-04-01 11:48 news.settingsorg.eclipse.wst.common.project.facet.core.xm
文件 49 2017-04-01 11:48 news.settingsorg.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-04-01 11:48 news.settingsorg.eclipse.wst.jsdt.ui.superType.name
文件 4823 2018-10-25 10:41 newssrccomactionAddNewAction.java
文件 2349 2017-04-11 10:04 newssrccomactionAddTopicAction.java
文件 2217 2017-04-11 10:11 newssrccomactionDelTopicAction.java
文件 2725 2017-04-18 08:52 newssrccomactionIndexAction.java
文件 3244 2017-04-15 09:45 newssrccomactionLoginAction.java
文件 2303 2017-04-11 10:42 newssrccomactionOneTopicAction.java
文件 2902 2017-04-11 08:51 newssrccomactionTestAction.java
文件 2719 2017-04-18 08:50 newssrccomactionTopicListAction.java
文件 2533 2017-04-11 10:52 newssrccomactionUpdateTopicAction.java
文件 253 2017-04-07 09:14 newssrccomdaoimpla
文件 981 2017-04-05 21:21 newssrccomdaoimplJdbcUtil.java
文件 4032 2017-04-15 11:06 newssrccomdaoimplTopicDao.java
文件 787 2017-04-07 09:37 newssrccomdaoimplUserDao.java
文件 353 2017-04-15 10:07 newssrccomdaoITopicDao.java
文件 151 2017-04-07 09:08 newssrccomdaoIUserDao.java
文件 2093 2017-03-06 11:42 newssrccomentityNews.java
文件 437 2017-03-06 11:42 newssrccomentityTopic.java
文件 611 2017-03-06 11:42 newssrccomentityUsers.java
文件 683 2017-04-15 09:42 newssrccomserviceimplAppUtil.java
文件 696 2017-04-15 11:12 newssrccomserviceimplTopicService.java
文件 347 2017-04-07 09:44 newssrccomserviceimplUserService.java
文件 366 2017-04-15 11:11 newssrccomserviceITopicService.java
............此处省略115个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)