零配置的问题(struts2+Hibernate)?
零配置的问题(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.java
package 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
------解决方案--------------------@ParentPackage("test")
@ParentPackage("struts-default")
在J2ME中应用Timer和TimerTask来实现多线程