零配置的问题(struts2+Hibernate):web.xml <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.rocky.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></web-app>
-------------------------------------------------struts.xml<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.ui.theme" value="simple"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.convention.result.path" value=""/><package name="test" namespace="com.rocky" extends="struts-default"></package></struts>
------------------------------------------LoginAction.javapackage com.rocky.action;
...import com.rocky.entity.LoginId;
@ParentPackage("test")
@Results( { @Result(name = "success", location = "/frame.jsp"),
@Result(name = "error", location = "/login.jsp") })
...public class LoginAction extends ActionSupport {
public String login() throws Exception{
try {
udi.login(loginId);
return "success";
} catch (Exception e) {
return "error";
}
}
--------------------------login.jsp 文件在WebRoot路径下,不是在WEB-INF里<form action="login!login.action" method="post">
...在IE里输入
http://ken:8080/Hibernate3/login.jsp
可以显示页面,但是点确定提交就错误:
There is no Action mapped for namespace [/] and action name [login] associated with context path [/Hibernate3]. - [unknown location] 这样写也一样错误
<form action="test!login.action" method="post">
<form action="login.action" method="post">IE里直接输入也错误:
http://ken:8080/Hibernate3/login.action
http://ken:8080/Hibernate3/login!login.action
http://ken:8080/Hibernate3/test!login.action
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.rocky.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></web-app>
-------------------------------------------------struts.xml<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.ui.theme" value="simple"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<constant name="struts.convention.result.path" value=""/><package name="test" namespace="com.rocky" extends="struts-default"></package></struts>
------------------------------------------LoginAction.javapackage com.rocky.action;
...import com.rocky.entity.LoginId;
@ParentPackage("test")
@Results( { @Result(name = "success", location = "/frame.jsp"),
@Result(name = "error", location = "/login.jsp") })
...public class LoginAction extends ActionSupport {
public String login() throws Exception{
try {
udi.login(loginId);
return "success";
} catch (Exception e) {
return "error";
}
}
--------------------------login.jsp 文件在WebRoot路径下,不是在WEB-INF里<form action="login!login.action" method="post">
...在IE里输入
http://ken:8080/Hibernate3/login.jsp
可以显示页面,但是点确定提交就错误:
There is no Action mapped for namespace [/] and action name [login] associated with context path [/Hibernate3]. - [unknown location] 这样写也一样错误
<form action="test!login.action" method="post">
<form action="login.action" method="post">IE里直接输入也错误:
http://ken:8080/Hibernate3/login.action
http://ken:8080/Hibernate3/login!login.action
http://ken:8080/Hibernate3/test!login.action
解决方案 »
- 关于论坛回复楼层显示的实现
- jquery插件validate怎么对struts标签进行验证?
- 检索数据库用Hashtable 的问题
- 如何用java或jsp实现压缩照片的预浏览????!!!!
- SSH+JQuery+ajax
- 第二次没有触发js函数,这是为啥?
- Hibernate自动生成表时如何使id从指定数开始增长
- 请问:如何比较2个日期相差的天数?
- 在jspsmart网站free download了那套上传程序,但为什么都提示这个错误Package com.jspsmart.upload not found in import.import com.jsps
- JSP中操作数据库是不是必须用BEAN?
- 用java程序生成网站地图
- fckeditor有弹出窗口功能的都不能使用
@ParentPackage("struts-default")
ParentPackage:指定父包。你要指定命名空间的话!
@Namespace("/test")
这样才是指定命名空间!
@ParentPackage("test")
@Namespace("/test")@ParentPackage("struts-default")
@Namespace("/test")这样都不对啊
http://ken:8080/Hibernate3/login!login.action
http://ken:8080/Hibernate3/test!login.action
这些连接不带.action试试
<url-pattern>/*</url-pattern>
设置的时候没有说/*.action
没有自己测试,只是看代码提出一个想法。
http://ken:8080/Hibernate3/login
http://ken:8080/Hibernate3/login!login
http://ken:8080/Hibernate3/test!login
这样都不对
你有命名空间的!
<package name="test" namespace="com.rocky" extends="struts-default">
</package>保持你原来的配置不变!
这样访问试试:
<form action="com.rocky/login.action" method="post">
不对:
There is no Action mapped for namespace [/] and action name [com.rocky] associated with context path [/Hibernate3].
不对:
There is no Action mapped for namespace [/] and action name [test] associated with context path [/Hibernate3].
你Action都没有配置
@Action("login")
public String login()配置好Action!
这样访问试试:
<form action="com.rocky/login.action" method="post">
<form action="/com.rocky/login.action" method="post">
<form action="login.action" method="post">
我真的是胡汉三 等级: 请加我QQ:184463552 一起讨论