求助用struts2框架进行校验时校验信息在控制台输出而不能显示到页面上!!login.jsp%@ page languagejava
求助用struts2框架进行校验时校验信息在控制台输出而不能显示到页面上!!
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆系统</title>
<!-- 此标志的作用是引入Struts 2.0的常用的Javascript和CSS -->
<s:head/>
</head>
<body>
<%@include file="common/header.jsp"%>
<table width="780" align="center" background="<%=ctx%>/images/bodybg.jpg">
<tr>
<td>
<h6>请输入用户名和密码来登陆<br></h6>
<s:if test="tip!=null">
<div class="error">
<s:property value="tip"/>
</div>
</s:if>
<s:actionerror cssClass="error"/>
<s:form action="login" name="form1" method="post" validate="true">
<s:textfield name="username" label="用户名"/>
<s:password name="password" label="密码"/>
<tr>
<td colspan="2">
<s:submit value="登录" theme="simple"/>
<s:reset theme="simple" value="重置" />
</td>
</tr>
</s:form>
</td>
</tr>
</table>
<%@include file="common/footer.jsp"%>
</body>
</html>
LoginAction
public class LoginAction extends UserBaseAction {
//登录的用户名
private String username;
//登录的密码
private String password;
//处理登录后的提示信息
private String tip;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
@SuppressWarnings("unused")
private boolean isInvalid(String value) {
return (value == null || value.length() == 0);
}
//处理用户请求
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
//创建ActionContext实例
ActionContext ctx = ActionContext.getContext();
//调用业务逻辑方法来处理登录请求
int loginResult = userService.Login(getUsername(), getPassword());
System.out.println(getUsername());
System.out.println(getPassword());
if(loginResult == userService.LOGIN_SUCCESS) {
ctx.getSession().put(Constants.USER, username);
setTip("您已经成功登陆系统");
// 设置session
Map map = ActionContext.getContext().getSession();
map.put("username", getUsername());
return Constants.LOGIN_SUCCESS;
} else { //用户名和密码不匹配
setTip("用户名/密码不匹配");
return Constants.LOGIN_FAIL;
}
}
}
struts:
<action name="login" class="cn.RptSystem.web.action.LoginAction">
<result name="input">/WEB-INF/jsp/login.jsp</result>
<result name="fail">/WEB-INF/jsp/login.jsp</result>
<result name="success">/WEB-INF/jsp/main.jsp</result>
</action>
控制台:
一月 09, 2014 3:10:43 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger fatal
严重: 元素内容必须由格式正确的字符数据或标记组成。 at (null:24:3)
org.xml.sax.SAXParseException; systemId: file:///D:/eclipse/cn/RptSystem/web/action/LoginAction-validation.xml; lineNumber: 24; columnNumber: 3; 元素内容必须由格式正确的字符数据或标记组成。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:113)
at com.opensymphony.xwork2.validator.DefaultValidatorFileParser.parseActionValidatorConfigs(DefaultValidatorFileParser.java:69)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.loadFile(AnnotationActionValidatorManager.java:329)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildClassValidatorConfigs(AnnotationActionValidatorManager.java:216)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildValidatorConfigs(AnnotationActionValidatorManager.java:308)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.getValidators(AnnotationActionValidatorManager.java:63)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:102)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:94)
at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:89)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:208)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:247)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
[解决办法]
[解决办法]
解决速度有点快。。。
[解决办法]
高手,佩服。佩服。
[解决办法]
我来拿分
[解决办法]
[解决办法]
拿分的来鸟