你在struts.xml中配置了名叫login的action吧?<a href="login.action">登录系统</a>这段代码就是表示访问的login这个action啊。
你这可以在LoginAction里面加一个方法:
public String execute() {
return "login".
}
这样就可以了。
你这可以在LoginAction里面加一个方法:
public String execute() {
return "login".
}
这样就可以了。
解决方案 »
- 大家帮我看看缺少了什么jar包?谢谢
- cas单点登录的权限问题
- 关于登录界面的验证码问题~
- 求助:重定向出错
- 现在在学习hibernate 问个很菜的问题 我们为什么要使用对象持久层
- SQLServerException: 索引 1 超出范围。
- 哪有weblogic的中文配置文档?请告诉下载地址,谢谢!
- 我想看weblogic.jar下的类,都是.class的,谁有办法??
- 关于在java程序里调用webservice报500返回码的问题
- myeclipse10整合ssh框架时发生Error occured processing XML 'Provider org.apache.xer。。。。
- request域的问题
- 高分求救!!cxf生成客户端代码,测试环境jdk1.6+WebLogic10.3报错
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
楼主的链接应该被struts过滤了,然后struts找到对应的action处理了
谢谢你的回复,但我写的是login.action跳转,不是页面跳转,经过action了
关键是struts.xml中没有配置名叫login的action
以下是我struts.xml的所有配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- 指定Struts2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<!-- Struts2配置文件的根元素 -->
<struts>
<!-- 配置了系列常量 -->
<constant name="struts.custom.i18n.resources" value="resource" />
<constant name="struts.i18n.encoding" value="utf-8" />
<constant name="struts.devMode" value="true" />
<package name="cb" extends="struts-default" >
<!-- 定义全局Result映射 -->
<global-results>
<!-- 定义全局Result映射 -->
<result name="business">/WEB-INF/content/error.jsp</result>
<result name="root">/WEB-INF/content/error.jsp</result>
<!-- 定义login逻辑视图对应的视图资源 -->
<result name="login">/WEB-INF/content/login.jsp</result>
</global-results>
</package>
</struts> 还有一个问题,就是说我LoginAction中即使没有继承ActionSupport,它也会执行execute()这个方法,但是我把这个方法名改个名字,它就不会执行了,太奇怪了,谢谢你的解答!
struts里都没有配置Login这个action,一共就三个全局Result映射
struts里都没有配置Login这个action,一共就三个全局Result映射能不能贴下你的action配置啊
struts里都没有配置Login这个action,一共就三个全局Result映射能不能贴下你的action配置啊7楼我贴出来了
关键是struts.xml中没有配置名叫login的action
以下是我struts.xml的所有配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- 指定Struts2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<!-- Struts2配置文件的根元素 -->
<struts>
<!-- 配置了系列常量 -->
<constant name="struts.custom.i18n.resources" value="resource" />
<constant name="struts.i18n.encoding" value="utf-8" />
<constant name="struts.devMode" value="true" />
<package name="cb" extends="struts-default" >
<!-- 定义全局Result映射 -->
<global-results>
<!-- 定义全局Result映射 -->
<result name="business">/WEB-INF/content/error.jsp</result>
<result name="root">/WEB-INF/content/error.jsp</result>
<!-- 定义login逻辑视图对应的视图资源 -->
<result name="login">/WEB-INF/content/login.jsp</result>
</global-results>
</package>
</struts> 还有一个问题,就是说我LoginAction中即使没有继承ActionSupport,它也会执行execute()这个方法,但是我把这个方法名改个名字,它就不会执行了,太奇怪了,谢谢你的解答!Struts本来就是这样的,你自己写的action不用继承ActionSupport也可以执行,只是这样你就不能用ActionSupport的一些功能了,比如validate()、addFieldError()等等。
关键是struts.xml中没有配置名叫login的action
以下是我struts.xml的所有配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- 指定Struts2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<!-- Struts2配置文件的根元素 -->
<struts>
<!-- 配置了系列常量 -->
<constant name="struts.custom.i18n.resources" value="resource" />
<constant name="struts.i18n.encoding" value="utf-8" />
<constant name="struts.devMode" value="true" />
<package name="cb" extends="struts-default" >
<!-- 定义全局Result映射 -->
<global-results>
<!-- 定义全局Result映射 -->
<result name="business">/WEB-INF/content/error.jsp</result>
<result name="root">/WEB-INF/content/error.jsp</result>
<!-- 定义login逻辑视图对应的视图资源 -->
<result name="login">/WEB-INF/content/login.jsp</result>
</global-results>
</package>
</struts> 还有一个问题,就是说我LoginAction中即使没有继承ActionSupport,它也会执行execute()这个方法,但是我把这个方法名改个名字,它就不会执行了,太奇怪了,谢谢你的解答!Struts本来就是这样的,你自己写的action不用继承ActionSupport也可以执行,只是这样你就不能用ActionSupport的一些功能了,比如validate()、addFieldError()等等。谢谢你的回答,这个问题我明白了,但是你能帮我看看,为什么LoginAction没在struts里面配置,但是它会自动加载吗?
package com.cb.hrsystem.action;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;public class LoginAction implements Action{
public String execute() throws Exception{
System.out.println("测试");
return "";
}
}
extends="struts-default"没有应用Struts-rest的包,7楼有struts.xml配置
其实你也别这么纠结一定要把这种问题刨根问底,按照struts2正常的配置来写就好了。
非常感谢你的回答!我自己找出什么问题了,我这个struts的版本估计有问题,我是2.2.1的,struts配置里面必须要namespace="/".否则,使用action的名字是login,logout都存在这个问题,会自己寻找loginaction,login.jsp!
非常感谢你的回答!我自己找出什么问题了,我这个struts的版本估计有问题,我是2.2.1的,struts配置里面必须要namespace="/".否则,使用action的名字是login,logout都存在这个问题,会自己寻找loginaction,login.jsp!
你是说struts2会对login、logout做特别处理吗?
非常感谢你的回答!我自己找出什么问题了,我这个struts的版本估计有问题,我是2.2.1的,struts配置里面必须要namespace="/".否则,使用action的名字是login,logout都存在这个问题,会自己寻找loginaction,login.jsp!
你是说struts2会对login、logout做特别处理吗?目前看来是这个问题,我只要使用这两个action的名字,都存在这个问题!就这样,结贴了额,感谢你们的回答