标题:Struts2的问题
只看楼主
gknl
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-7-29
 问题点数:0 回复次数:1 
Struts2的问题

  我用Struts2做了一个登录程序,index.jsp是这样的
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Login</title>
</head>
<body>
<s:form action="Login" method="POST">
<s:textfield name="user.username" label="User name"/>
<s:password name="user.password" label="Password"/>
<s:submit value="Submit"/>
</s:form>
</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>
<include file="struts-default.xml" />
<package name="package1" extends="struts-default">
<action name="Login" class="org.fcb.login.action.LoginAction">
<result name="SUCCESS">HelloWorld.jsp</result>
<result name="ERROR">error.jsp</result>
</action>
</package>
</struts>
web.xml是这样的
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Struts 2.0 Hello World</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>
此外还有个user bean类
private String name ;
private String passWord ;
还有个action
package org.fcb.login.action;

import org.fcb.login.vo.User;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class LoginAction extends ActionSupport {
private User user = new User() ;
private String message ;
public String getMessage()
{
return message;
}
@Override
public String execute() throws Exception
{
if("max".equals(user.getName())&&"123456".equals(user.getPassWord()))
{
message = "欢迎光临!!! " ;
return ActionSupport.SUCCESS ;
}else
{
message = "用户名或密码错误" ;
return ActionSupport.ERROR ;
}

}

}
结果报错
警告: Internal Error: File /WEB-INF/web.xml not found
2007-9-10 21:47:29 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: File "/struts-tags" not found
.......
我把struts2所有的包都导进去了

搜索更多相关主题的帖子: name body form label 
2007-09-10 21:59
gknl
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-7-29
得分:0 
tomcat启动没问题啊,然后在别的机上运行可以,这下把我搞晕了

2007-09-10 22:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-169007-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.264156 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved