14 个解决方案
#1
贴下struts.xml的配置,还有你的访问路径。
#2
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
<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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
#3
本地访问http://localhost:8080/struts_login/
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm"
type="com.bjpowernode.struts.LoginActionForm"/>
</form-beans>
<action-mappings>
<action path="/login"
type="com.bjpowernode.struts.LoginAction"
name ="loginForm"
scope="request"
>
<forward name="success" path="/login_success.jsp"/>
<forward name="error" path="/login_error.jsp"/>
</action>
</action-mappings>
</struts-config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm"
type="com.bjpowernode.struts.LoginActionForm"/>
</form-beans>
<action-mappings>
<action path="/login"
type="com.bjpowernode.struts.LoginAction"
name ="loginForm"
scope="request"
>
<forward name="success" path="/login_success.jsp"/>
<forward name="error" path="/login_error.jsp"/>
</action>
</action-mappings>
</struts-config>
#4
用http://localhost:8080/struts_login/login.do访问试试
#5
还是不行
#6
type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
#7
可以点击呀
#8
是不是tomcat的配置有问题呀
#9
在execute方法里面打印个东西,请求下,看有没有进入到方法里。会不会是跳转到页面的时候404了。
#10
你都正常启动了,有什么问题?难道你改配置了?
#11
是不是tomcat的配置有问题呀 type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
你都正常启动了,有什么问题?难道你改配置了?
#12
在execute方法里面打印个东西,请求下,看有没有进入到方法里。会不会是跳转到页面的时候404了。
#13
话说你项目部署到上面了么?去tomcat的webapps底下看看有没有这个项目,或者eclipse的server下面看看。
#14
问题找到了,login.jsp放在了WEB.INF里面,而我用的是<a>标签跳转。
如果是html页面且在WEB-INF外面,可以直接跳转
如果在WEB-INF里面的页面,就必须通过servlet去跳转了。
如果是html页面且在WEB-INF外面,可以直接跳转
如果在WEB-INF里面的页面,就必须通过servlet去跳转了。
#1
贴下struts.xml的配置,还有你的访问路径。
#2
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
<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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
#3
本地访问http://localhost:8080/struts_login/
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm"
type="com.bjpowernode.struts.LoginActionForm"/>
</form-beans>
<action-mappings>
<action path="/login"
type="com.bjpowernode.struts.LoginAction"
name ="loginForm"
scope="request"
>
<forward name="success" path="/login_success.jsp"/>
<forward name="error" path="/login_error.jsp"/>
</action>
</action-mappings>
</struts-config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm"
type="com.bjpowernode.struts.LoginActionForm"/>
</form-beans>
<action-mappings>
<action path="/login"
type="com.bjpowernode.struts.LoginAction"
name ="loginForm"
scope="request"
>
<forward name="success" path="/login_success.jsp"/>
<forward name="error" path="/login_error.jsp"/>
</action>
</action-mappings>
</struts-config>
#4
用http://localhost:8080/struts_login/login.do访问试试
#5
用http://localhost:8080/struts_login/login.do访问试试
#6
type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
#7
type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
#8
type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
#9
在execute方法里面打印个东西,请求下,看有没有进入到方法里。会不会是跳转到页面的时候404了。
#10
是不是tomcat的配置有问题呀 type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
你都正常启动了,有什么问题?难道你改配置了?
#11
是不是tomcat的配置有问题呀 type="com.bjpowernode.struts.LoginAction",这个也没问题么?是不是类名写错了,Ctrl下看能不能点击
你都正常启动了,有什么问题?难道你改配置了?
#12
在execute方法里面打印个东西,请求下,看有没有进入到方法里。会不会是跳转到页面的时候404了。
#13
话说你项目部署到上面了么?去tomcat的webapps底下看看有没有这个项目,或者eclipse的server下面看看。
#14
问题找到了,login.jsp放在了WEB.INF里面,而我用的是<a>标签跳转。
如果是html页面且在WEB-INF外面,可以直接跳转
如果在WEB-INF里面的页面,就必须通过servlet去跳转了。
如果是html页面且在WEB-INF外面,可以直接跳转
如果在WEB-INF里面的页面,就必须通过servlet去跳转了。