使用Strust2的校验框架

Gemini1995 Gemini1995 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
运行网页显示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>


...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
Gemini1995
研发管理 1,268 成员 28,280 内容