ConvertorAction.java代码如下:package com.hc.struts2.action;
import java.sql.Time;
import java.util.Date;import com.opensymphony.xwork2.ActionSupport;public class ConvertorAction extends ActionSupport {
private Date sqlDate;
private Time sqlTime;
private java.util.Date utilDate;

public String execute()
{
return INPUT;
}
public String convert()
{
return SUCCESS;
}
}convert.jsp如下:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="/struts-tags" prefix="struts"  %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My jsp 'index.jsp' starting page</title></head><body>
<struts:form action="convertor">
<struts:label value="转换器"></struts:label>
<struts:textfield name="sqlDate" label="SQL Date:" />
<struts:textfield name="sqlTime" label="SQL Time:" />
<struts:textfield name="utilDate" label="Util Date:" /><struts:submit value="登录" method="convert"></struts:submit>
</struts:form>>
</body>
</html>convertSuccess.jsp代码如下:<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="/struts-tags" prefix="struts"  %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
java.sql.Date: <struts:property value="sqlDate" /></br>
java.sql.Time:<struts:property  value="sqlTime"/></br>
java.util.Date:<struts:property  value="utilDate"/></br>
</br>
<a href="convertor.action">&lt;&lt;重新转换 </a></body>
</html>struts.xml配置如下:
<!DOCTYPE struts PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
          "http://struts.apache.org/dtds/struts-2.0.dtd">
          
<struts>
    <package name="main" extends="struts-default">
        <global-results>
        <result name="login">/login.jsp</result>
        </global-results>
              
        <action name="convertor" class="com.hc.struts2.action.ConvertorAction" >
         <result name="input">/convert.jsp</result>
            <result name="success">/convertSuccess.jsp</result>
        </action>
    </package>
</struts>在convert.jsp页面点convert按钮,没有调到action里面去,报错说description The requested resource (/struts2/convertor) is not available.我是新手,请高手指点一下,到底是什么地方出错了。

解决方案 »

  1.   

    在form里 敢不敢 加个.action
      

  2.   

    public String execute() throws Exception
    {
    return INPUT;
    }
      

  3.   

    上面贴的是我涉及到的几个文件的全部代码,请高手把代码copy到本地运行一下,帮我看看什么原因。
      

  4.   

    private Date sqlDate;
    private Time sqlTime;
    private java.util.Date utilDate;这些都要是用字符串来转化的,那在它的转化器里,有它的默认格式转化。
      

  5.   

    <struts:form action="convertor.action">
    如果不行就改为
    <struts:form action="convertor!convert">
    <struts:label value="转换器"></struts:label>
    <struts:textfield name="sqlDate" label="SQL Date:" />
    <struts:textfield name="sqlTime" label="SQL Time:" />
    <struts:textfield name="utilDate" label="Util Date:" /><struts:submit value="登录"/>
    </struts:form>>
    </body>
      

  6.   

    web.xml加FilterDispather拦截器的配置了没?
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apacher.struts2.dispatcher.FilterDispather</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>而且还要导入xxx.jar包,最少5个。。
      

  7.   

    1、struts.xml配置文件是否放在src根目录下
    2、所有jar包是否导入
    3、web.xml是否配置
    4、Action中execute方法最好自动生成别自己写