尝试将hibernate集成到struts2框架中 不知道我做错了什么。 Jetty无法找到jsp的
SEVERE: PWC6117: File "/Users/juliusskye/flightpub/src/main/webapp/pages/login.jsp" not found
struts文件
<struts>
<!-- Configuration for the default package. -->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="Pages" namespace="/pages" extends="struts-default">
<action name="login"
method ="authenticate"
class="FPG2.view.LoginAction">
<result name="success">/pages/welcome.jsp</result>
<result name="error">/pages/login.jsp</result>
</action>
<action name="results"
method ="execute"
class="FPG2.view.ResultsAction">
<result name="success">/pages/error.jsp</result>
<result name="error">/pages/results.jsp</result>
</action>
</package>
</struts>
登录操作类
package FPG2.view;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
public static final String USERNAME = "label.username";
public static final String PASSWORD = "label.password";
private String username = "Username";
private String password = "Password";
public String authenticate() {
if (this.username.equals("admin")
&& this.password.equals("admin123")) {
return "success";
} else {
addActionError(getText("error.login"));
return "error";
}
}
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;
}
}
的login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>FlightPub - Login Page</title>
</head>
<body>
<h2>Struts 2 - Login Application</h2>
<s:actionerror />
<s:form action="login.action" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="authenticate" key="label.login" align="center" />
</s:form>
</body>
</html>
的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>FlightPub</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
答案 0 :(得分:0)
你在struts.xml中定义了错误的路径,你忘记了WEB-INF文件夹