使用Strust2的校验框架

Gemini1995 学生  2015-10-21 10:25:36
运行网页显示404错误,连着好几天不能解决,求大神指点
type Status report

message /5-4-2/

description The requested resource (/5-4-2/) is not available.

代码具体如下
struts.xml
<?xml version="1.0" encoding="GBK"?>
<struts>
<constant name="struts.devMode" value="true"/>
<constant name="struts.custom.il8n.resources" value="properties/myMessages"/>
<constant name="struts.il8n.encoding" value="GBK"/>
<package name="struts2_validate" extends="struts-default">
<action name="ValidationAction" class="com.ascent.action.ValidationAction">
<result>/Output.jsp</result>
<result name="input">/Input.jsp</result>
</action>
</package>
</struts>
ValidationAction.java
package com.ascent.action;
import com.opensymphony.xwork2.ActionSupport;
public class ValidationAction extends ActionSupport{
private static final long serialVersionUID=1L;
private String reqiuredString ;
public String getReqiuredString()
{
return reqiuredString;

}
public void setReqiuredString(String reqiuredString)
{
this.reqiuredString=reqiuredString;

}

public String execuye()
{
return SUCCESS;
}

}
ValidationAction-validation.xml
<?xml version="1.0" encoding="UTF-8"?>


<validators>
<field name="reqiuredString">
<field-validator type="reqiuredstring">
<message>This string is required </message>
</field-validator>
</field>
</validators>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


<display-name>Struts2</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Input.jsp
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<title>Validation</title>
<s:head/>
</head>

<body>

<s:form action="ValidationAction">
<s:textfield name="reqiuredString" lable="Required String"/>
<s:submit/>
</s:form>
</body>
</html>
Output.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%@taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<title>Validation</title>
</head>

<body>
Required String:<s:property value="reqiuredString"/>
</body>
</html>


...全文
342 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Gemini1995 2015-10-21
求大神帮忙
回复
相关推荐
发帖
研发管理
创建于2007-08-27

1221

社区成员

软件工程/管理 管理版
申请成为版主
帖子事件
创建了帖子
2015-10-21 10:25
社区公告
暂无公告