输入地址:http://localhost:8080/xxxx/xxx/xxxxx/edcourse.jsp
edcourse.jsp:<s:if test="#request.boolfirst==null">
<s:action name="xxx_xxxxx" namespace="/xxxxx"></s:action>
</s:if>
public String xxxxx(){
try {
if(lecturer.getId()!=null)
{
Lecturer TempLecturer= lecturerBiz.findLecturer(lecturer.getId());
if(TempLecturer!=null)
{
request.put("boolfirst", true);
request.put("TempLecturer", TempLecturer);
return "edcourse";
}
else
{
return "error";
}
}
return "error";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
// logger.error("类名:"+this.getClass().getName()+
// "||方法名:"+Thread.currentThread().getStackTrace()[1].getMethodName()+
// "||错误信息:"+e.toString());
//输出错误信息到log4j产生的文件中
}
return "error";
}
能保证http://localhost:8080/xxxx/xxx/xxxxx/edcourse.jsp能走到xxxxx方法里面
如果lecturer.getId()不为空的话 能找到值 并且跳转到Struts2配置文件中result name 为edcourse的页面。、
但是lecturer.getId()为空的话 是不是跳转到Struts2配置文件中result name为error的页面。、
问题来了:lecturer.getId()为空的时候 刷新 不会跳转 会走一遍查找过程,不跳转到Struts2配置文件中result name为error的页面。而是在本页、
Why???难道Action只对.action的请求才会跳转么?
edcourse.jsp:<s:if test="#request.boolfirst==null">
<s:action name="xxx_xxxxx" namespace="/xxxxx"></s:action>
</s:if>
public String xxxxx(){
try {
if(lecturer.getId()!=null)
{
Lecturer TempLecturer= lecturerBiz.findLecturer(lecturer.getId());
if(TempLecturer!=null)
{
request.put("boolfirst", true);
request.put("TempLecturer", TempLecturer);
return "edcourse";
}
else
{
return "error";
}
}
return "error";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
// logger.error("类名:"+this.getClass().getName()+
// "||方法名:"+Thread.currentThread().getStackTrace()[1].getMethodName()+
// "||错误信息:"+e.toString());
//输出错误信息到log4j产生的文件中
}
return "error";
}
能保证http://localhost:8080/xxxx/xxx/xxxxx/edcourse.jsp能走到xxxxx方法里面
如果lecturer.getId()不为空的话 能找到值 并且跳转到Struts2配置文件中result name 为edcourse的页面。、
但是lecturer.getId()为空的话 是不是跳转到Struts2配置文件中result name为error的页面。、
问题来了:lecturer.getId()为空的时候 刷新 不会跳转 会走一遍查找过程,不跳转到Struts2配置文件中result name为error的页面。而是在本页、
Why???难道Action只对.action的请求才会跳转么?
解决方案 »
- JNDI 中,Java:comp /env是绑定到容器环境命名上下文的名字。求详细解释啊,小弟不理解。
- TOMCAT的测试,高手请进!
- openmica开源的MVC??有谁用过,介绍一下,
- 我在nz_gdlist.action中无法获取到Mchz,请高手指教!!!
- 请教 关于tomcat6.0数据库连接池与虚拟路径的配置
- 将购物车以多例模式的方式实现,这样做怎么样呢?
- 统计一下用Spring+Hibernate+Webwork的人多还是用Spring+Hibernate+Struct的人多!
- 哪儿错了?
- TOMCAT里如何配置连接池呀?
- ***禁止重复登录?***
- 转义问题
- 深圳软通动力怎么样?
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
你配了action干嘛还要在页面内嵌代码
你还是把你了解的说出来吧
{ document.location.href="XX/XX/XX!XXX.action?id="+id;
alert("错误页面");
document.location.href="XX/XX/XXX!.action";}
在struts.xml配置<constant name="struts.action.extension" value="shtml" />
在web.xml配置
<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>红色字体是你想要设置的action匹配的url扩展名