--------------------------------jsp-------------------------------------------addnews.jsp-----------<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
    
    <title>addnews.jsp</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">
  </head>
  
  <body>
    <br>
    <table width="500" border="0" align="center">
      <tr>
        <td>addnews
        </td>
      </tr>
      <tr>
        <td>
<form name="form1" method="post" action="/ldweb/test.do">
  <table width="500" border="0">
            <tr>
              <td><table width="500" border="0">
                <tr>
                  <td width="150">title</td>
                  <td><input type="text" name="title"></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table width="500" border="0">
                <tr>
                  <td width="150">author</td>
                  <td><input type="text" name="author"></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><table width="500" border="0">
                <tr>
                  <td width="150">content</td>
                  <td><textarea name="content" rows="10"></textarea>
                  <input type="submit" name="Submit" value="tijiao"></td>
                </tr>
              </table></td>
            </tr>
          </table>
        </form></td>
      </tr>
    </table>
  </body>
</html:html>-----------------ok.jsp-----------------<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
    
    <title>ok.jsp</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">
  </head>
  
  <body>
    This a struts page. <br>
    ok<br>
  </body>
</html:html>
-------------------------------java---------------------------
-----------------NewsForm.java-----
package com.ld.struts;public class NewsForm {
private String title = ""; private String author = ""; private String content = ""; public String getAuthor() {
return author;
} public void setAuthor(String author) {
this.author = author;
} public String getContent() {
return content;
} public void setContent(String content) {
this.content = content;
} public String getTitle() {
return title;
} public void setTitle(String title) {
this.title = title;
}}----------------NewsAction.java---------------------
package com.ld.struts;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.ld.model.*;public class NewsAction extends Action {
private static final long serialVersionUID = 1L; public ActionForward execute(ActionMapping mapping, NewsForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception { // this line is here for when the
// input page is upload-utf8.jsp, // it sets the correct character
// encoding for the response /*String encoding = request.getCharacterEncoding(); if ((encoding != null) && (encoding.equalsIgnoreCase("GB2312"))) { response.setContentType("text/html; charset=GB2312"); } else { response.setContentType("text/html; charset=GB2312"); } try { if (form instanceof NewsForm) { NewsForm theForm = (NewsForm) form; if (theForm.getAuthor().equals("user") && theForm.getTitle().equals("123456")) { return new ActionForward("/ok.do?type=true"); } else { return new ActionForward("/ok.do?type=false"); } }
} catch (Exception e) { } // this shouldn't happen in this example
addnews ad=new addnews();
        ad.writenews();
return null;*/
//以上都被注释了
           return new ActionForward("/ok.do");
      
}
}-----------------------------struts-config-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" 
"http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans>
<form-bean name="newsForm" type="com.ld.struts.NewsForm" />
</form-beans> <global-exceptions />
<global-forwards /> <action-mappings>
<action path="/addnews" forward="/addnews.jsp" />
<action path="/ok" forward="/ok.jsp"/>
<action path="/test" type="com.is.struts.NewsAction"
name="newsForm"/>
</action-mappings> <message-resources parameter="com.ld.struts.ApplicationResources" />
</struts-config>------------------------------------------------------------
服务器是tomcat5.0.28 
jdk 是1.4.2_10---------------------------出现如下异常-----------------------------
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.IllegalArgumentException: Resources cannot be null.
org.apache.commons.validator.Validator.<init>(Validator.java:188)
org.apache.struts.validator.Resources.initValidator(Resources.java:475)
org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:104)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:928)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
--------------------------------------------------------------------------------Apache Tomcat/5.0.30------------------------------------------------感谢---------------
各位,帮忙看看,解决问题者得分哦~~~~谢谢~~