快疯了,请大家帮忙找问题。一直报这个错误。
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 5 6 <filter> 7 <filter-name>struts2</filter-name> 8 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 9 <!-- <init-param> 10 <param-name>filterConfig</param-name> 11 <param-value>classpath:struts.xml</param-value> 12 </init-param> 13 --> 14 </filter> 15 16 <filter-mapping> 17 <filter-name>struts2</filter-name> 18 <url-pattern>/*</url-pattern> 19 </filter-mapping> 20 21 <welcome-file-list> 22 <welcome-file>index.html</welcome-file> 23 </welcome-file-list> 24 25 </web-app>
web.xml
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE struts PUBLIC 3 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" 4 "http://struts.apache.org/dtds/struts-2.3.dtd"> 5 6 <struts> 7 <!-- Struts2 的 Action都必须配置在package里 --> 8 <package name="default" namespace="/" extends="struts-default"> 9 <action name="loginAction" class="org.crazyit.action.LoginAction"> 10 <result name="success">/detils.jsp</result> 11 </action> 12 13 14 </package> 15 16 17 18 19 </struts>
struts.xml
package org.crazyit.action; public class LoginAction { // 封装用户请求参数的username属性 private String username; // 封装用户请求参数的password属性 private String password; 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; } //处理用户请求的execute方法 public String execute() throws Exception{ if(getUsername().equals("wangning")&& getPassword().equals("123456")){ return "success"; }else{ return "error"; } } }
loginAction
时间: 2024-11-13 06:43:46