毕业设计(十八)---发表文章(4)之- 发表文章流程 表单,处理代码


流程: 一表单 二处理.........代码:

\


表单:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	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>My JSP 'newPost.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor_config_fabiao.js"></script>

<style type="text/css">
#type {
	float: left;
	height: 24px;
	margin-right: 2px;
	padding: 2px;
	border: 1px solid #CCCCCC;
}
.subtit {
	border-bottom: 1px solid #F5F5F5;
	clear: both;
	color: #999999;
	font-weight: bold;
	padding: 12px 4px 2px;
}
#newArt {
	margin-top: 40px;
	margin-left: auto;
	margin-right: auto;
	width: 800px;
	margin-left: auto;
}
.radioBoxchannel input {
	margin-right: 0;
}
.radioBoxchannel label {
	font-size: 13px;
}
.input_btn_1 {
	background: url("homepage/images/btn.jpg") repeat-x scroll 0 center
		transparent;
	border: medium none;
	color: #FFFFFF;
	cursor: pointer;
	font: bold 12px/30px Arial, Helvetica, sans-serif;
	height: 30px;
	padding: 0 15px;
	text-align: center;
	width: auto;
}
</style>
<script type="text/javascript">
	function closethis() {
		if (confirm("放弃编辑并关闭?")) {
			window.opener = null;
			//window.opener=top;    
			window.open("", "_self");
			window.close();
		}
	}
</script>
</head>

<body>
	<div id="newArt">
	<form action="newarticle" method="post" >		
			<h2>发表新文章</h2>
			<div>
				<p class="subtit">文章标题.</p>
				<select name="texttype" id="type">
					<option value="1" selected="selected">原创</option>
					<option value="2">转载</option>
					<option value="3">翻译</option>
				</select> <input type="text" maxlength="100" name="title"
					style="width:560px; height:24px; float:left;" id="txtTitle">
			</div>
			<div>
				<p class="subtit">文章内容.</p>
				<br />
				<textarea name="content" id="TextArea1" class="ckeditor"></textarea>
			</div>
			<div>
				<p class="subtit">文章分类(到分类首页).</p>
				<br />
				<div class="radioBoxchannel">
					<input id="radChl1" type="radio" value="1" name="model"> <label
						for="radChl1">移动开发</label> <input id="radChl2" type="radio"
						value="2" name=model> <label for="radChl2">Web前端</label> <input
						id="radChl3" type="radio" value="3" name="model"> <label
						for="radChl3">架构设计</label> <input id="radChl4" type="radio"
						value="4" name="model"> <label for="radChl4">编程语言</label>
					<input id="radChl5" type="radio" value="5" name="model"> <label
						for="radChl5">互联网</label> <input id="radChl6" type="radio"
						value="6" name="model"> <label for="radChl6">数据库</label> <input
						id="radChl7" type="radio" value="7" name="model"> <label
						for="radChl7">系统运维</label> <input id="radChl8" type="radio"
						value="8" name="model"> <label for="radChl8">云计算</label> <input
						id="radChl9" type="radio" value="9" name="model"> <label
						for="radChl9">研发管理</label> <input id="radChl10" type="radio"
						value="10" name="model"> <label for="radChl10">综合</label>
				</div>
			</div>
			<div style="text-align:center;margin-top:25px;">
				<input  class="input_btn_1" type="submit" 
					value="发表文章">     <input 
					class="input_btn_1" type="button" οnclick="closethis();" value="舍弃">
			</div>
		</form>
	</div>
</body>
</html>

服务器处理Action:

@Component("ActionArticle")
@Scope("prototype")
public class ActionArticle extends ActionSupport {
	private String title;
	private int texttype;
	private int model;
	private String content;
	private Manager manager;

	public Manager getManager() {
		return manager;
	}
	@Resource
	public void setManager(Manager manager) {
		this.manager = manager;
	}
//...省略set get 方法
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println("aaa");
		Article art = new Article();

		art.setTitle(title);
		art.setTexttype(texttype);
		
		art.setContent(content);
		Model m = new Model();
		m = manager.findModelByid(model);
		art.setModel(m);
		Users u = (Users) ActionContext.getContext().getSession().get("user");
		art.setUsers(u);
		java.sql.Timestamp newPostTime = new java.sql.Timestamp(
				new java.util.Date().getTime());
		art.setTime(newPostTime);
		art.setIsEssence(false);
		art.setReadNum(0);
		
		manager.saveArticle(art);
		
		ActionContext.getContext().getSession().put("art", art);

		return SUCCESS;

	}

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值