9、バグ修正及び削除機能実現
バグ修正及び削除機能の実現
1、log4j-1.2.15バージョンのバグは、使用しないことを推奨し、log 4 j-1.2を推奨します.14
参照
After upgrading from 1.2.14 to 1.2.15 the following error show up during
shutdown:
log4j:ERROR LogMananger.repositorySelector was null likely due to error in
class
reloading, using NOPLoggerRepository.
No errors at all with 1.2.14
This probably is related to bug 40212
2、${org.parent.name}に対応し、orgがトップレベルの機構である場合、エラーポインタ異常を返し、修正する
Organization.hbm.xml not-found=「ignore」を追加:
Organization.JAva not-found=「ignore」を追加:
を選択します.
3、機構の唯一の番号を追加し、OrgManagerImplを修正する.JAvaのaddOrg(Organization org,int parentId)メソッドは、次のとおりです.
public_del_success.jspファイル:
public_update_success.jspファイル:
update_add_succes.jspファイル
DelOrgAction.JAvaファイル
OrgManagerImplを変更します.JAvaのdeleteOrg(int orgId)メソッドは、次のとおりです.
を選択します.
strutsを変更xmlファイルは次のとおりです.
tomcatを起動して、テストします!
1、log4j-1.2.15バージョンのバグは、使用しないことを推奨し、log 4 j-1.2を推奨します.14
参照
After upgrading from 1.2.14 to 1.2.15 the following error show up during
shutdown:
log4j:ERROR LogMananger.repositorySelector was null likely due to error in
class
reloading, using NOPLoggerRepository.
No errors at all with 1.2.14
This probably is related to bug 40212
2、${org.parent.name}に対応し、orgがトップレベルの機構である場合、エラーポインタ異常を返し、修正する
Organization.hbm.xml not-found=「ignore」を追加:
<many-to-one column="pid" access="field" name="parent" not-found="ignore"/>
Organization.JAva not-found=「ignore」を追加:
/**
* @hibernate.many-to-one
* column="pid" not-found="ignore"
*/
private Organization parent;
index.jsp修正<td align="center" vAlign="center">
<c:out value="${org.parent.name}"></c:out>
</td>
を選択します.
<td align="center" vAlign="center">
<c:if test="${!empty org.parent.name}">
<c:out value="${org.parent.name}"></c:out>
</c:if>
</td>
3、機構の唯一の番号を追加し、OrgManagerImplを修正する.JAvaのaddOrg(Organization org,int parentId)メソッドは、次のとおりです.
public void addOrg(Organization org, int parentId) {
if(parentId != 0)
org.setParent((Organization)getHibernateTemplate().load(Organization.class, parentId));
getHibernateTemplate().save(org);
//TODO
org.setSn(org.getParent() == null ? "" + org.getId(): org.getParent().getId() + "_" + org.getId());
getHibernateTemplate().update(org);
}
4、削除機能を完成する:public_del_success.jspファイル:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title> </title>
<script type="text/javascript">
function closewindow(){
window.returnValue = true;
window.close();
}
function clock(){
i = i -1;
if(document.getElementById("info")){
document.getElementById("info").innerHTML = " "+i+" ";
}
if(i > 0)
setTimeout("clock();",1000);
else
closewindow();
}
var i = 4;
clock();
</script>
</head>
<body>
<center>
!<p>
<div id="info"> 3 </div>
<input type="button" value=" " onclick="closewindow();">
</center>
</body>
</html>
public_update_success.jspファイル:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title> </title>
<script type="text/javascript">
function closewindow(){
if(window.opener){
window.opener.location.reload(true);
window.close();
}
}
function clock(){
i = i -1;
if(document.getElementById("info")){
document.getElementById("info").innerHTML = " "+i+" ";
}
if(i > 0)
setTimeout("clock();",1000);
else
closewindow();
}
var i = 4;
clock();
</script>
</head>
<body>
<center>
!<p>
<div id="info"> 3 </div>
<input type="button" value=" " onclick="closewindow();">
</center>
</body>
</html>
update_add_succes.jspファイル
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title> </title>
<script type="text/javascript">
function closewindow(){
if(window.opener){
window.opener.location.reload(true);
window.close();
}
}
function clock(){
i = i -1;
if(document.getElementById("info")){
document.getElementById("info").innerHTML = " "+i+" ";
}
if(i > 0)
setTimeout("clock();",1000);
else
closewindow();
}
var i = 4;
clock();
</script>
</head>
<body>
<center>
!<p>
<div id="info"> 3 </div>
<input type="button" value=" " onclick="closewindow();">
</center>
</body>
</html>
DelOrgAction.JAvaファイル
package com.oa.action;
import com.oa.manager.OrgManager;
import com.opensymphony.xwork2.ActionSupport;
public class DelOrgAction extends ActionSupport {
private OrgManager orgManager;
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public void setOrgManager(OrgManager orgManager) {
this.orgManager = orgManager;
}
@Override
public String execute() throws Exception {
orgManager.deleteOrg(id);
return "del_success";
}
}
OrgManagerImplを変更します.JAvaのdeleteOrg(int orgId)メソッドは、次のとおりです.
public void deleteOrg(int orgId) {
Organization org = (Organization) getHibernateTemplate().load(Organization.class, orgId);
if(org.getChildren().size() > 0)
throw new RuntimeException(" , !");
getHibernateTemplate().delete(getHibernateTemplate().load(Organization.class, orgId));
}
indexを修正する.jspファイル<a href="#" onclick="del('del.do?mentod=del&id=${org.id }');"> </a></td>
を選択します.
<a href="#" onclick="del('del.action?id=${org.id }');"> </a></td>
strutsを変更xmlファイルは次のとおりです.
<package name="struts2" namespace="/" extends="struts-default">
<global-results>
<result name="add_success">/common/pub_add_success.jsp</result>
<result name="del_success">/common/pub_del_success.jsp</result>
<result name="update_success">/common/pub_update_success.jsp</result>
</global-results>
<action name="Login" class="loginAction">
<result name="success">/result.jsp</result>
<result name="input">/login.jsp</result>
</action>
<action name="org" class="orgAction">
<result name="success">/org/index.jsp</result>
</action>
<action name="add_input" class="orgAction" method="add">
<result name="success">/org/add_input.jsp</result>
</action>
<action name="add" class="addAction">
<result name="success">/common/pub_add_success.jsp</result>
</action>
<action name="del" class="delAction"></action>
</package>
applicationContext-actions.xmlファイルに追加:<bean id="addAction" class="com.oa.action.AddOrgAction">
<property name="orgManager" ref="orgManager"/>
</bean>
<bean id="delAction" class="com.oa.action.DelOrgAction">
<property name="orgManager" ref="orgManager"/>
</bean>
tomcatを起動して、テストします!