我目前能够使用以下代码创建Windows事件日志:
string sSource;
string sLog;
string sEvent;
sSource = "Sample App";
sLog = "Application";
sEvent = "Sample Event";
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource,sLog);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 11111);
Run Code Online (Sandbox Code Playgroud)
这将在应用程序日志中创建一个日志.我想在事件日志中为事件添加多行数据,以便在调试时我可以直接解析日志以解决问题.此外,我查看了应用程序日志中的一些其他日志,它们似乎有一个二进制数据字段.我无法弄清楚如何编写这样的字段,因为上面的代码只添加了一个EventData字段.
我试图在Struts2上构建一个页面,为数据库表添加值.问题是,页面必须允许用户向数据库表输入多行.当用户单击"提交"时,它必须读取和写入数据库表的行.用户可以在页面中添加或删除行
因此,我尝试在页面上呈现List值.Java代码如下所示:
List<Testimate> estimates;
private String removeIndex;
public String execute() throws Exception {
estimates = new ArrayList<Testimate>();
for(int i = 0; i < INITIAL_ESTIMATES; i++)
estimates.add(new Testimate());
return INPUT;
}
public String add() {
estimates.add(new Testimate());
System.out.println(estimates.size());
return INPUT;
}
public String remove() {
estimates.remove(Integer.parseInt(getRemoveIndex()));
System.out.println(estimates.size() + " " + getRemoveIndex());
return INPUT;
}
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)And the page looks something like this:
<script>
setRemoveIndex()
{
$('input[name="removeIndex"]').val(removeIndex);
return true;
}
</script>
<s:form theme="custom" onsubmit="setRemoveIndex()">
<s:submit action="CEST02_add" cssClass="ButtonSmall" value="Add estimate" />
<s:hidden name="removeIndex"/> …Run Code Online (Sandbox Code Playgroud)