<struts-config>
??? <form-beans>
??????? <form-bean name="loginForm" type="com.allanlxf.action.LoginForm"/>
??????? <form-bean name="userForm" type="org.apache.struts.action.DynaActionForm">
??????????? <form-property name="userName" type="java.lang.String" />
??????????? <form-property name="password" type="java.lang.String" />
??????? </form-bean>
??? </form-beans>
???
??? <action-mappings>
???
??????? <action?? path="/core/login"? type="com.allanlxf.action.LoginAction"
?????????????????? name="loginForm" input="/core/login.jsp" validate="true" scope="request">
????????? <exception key="errors.root"
?????????????????????? path="/core/error.jsp"
?????????????????????? type="com.allanlxf.biz.IllegalUserException" />
????????? <forward name="success" path="/core/success.jsp" redirect="true"/>
????????? <forward name="fail" path="/core/fail.jsp" />
??????? </action>
???????
??????? <action?? path="/dispatch"? type="com.allanlxf.struts.actions.UserAction" parameter="method">
????????? <forward name="login" path="/actions/pages/login_next.jsp" />
????????? <forward name="find" path="/actions/pages/find_next.jsp" />
????????? <forward name="findById" path="/actions/pages/findById_next.jsp" />
????????? <forward name="remove" path="/actions/pages/remove_next.jsp" />
????????? <forward name="modify" path="/actions/pages/modify_next.jsp" />
????????? <forward name="register" path="/actions/pages/register_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/login"? type="com.allanlxf.struts.actions.UserMappingAction" parameter="login">
????????? <forward name="next" path="/actions/pages/login_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/find"? type="com.allanlxf.struts.actions.UserMappingAction"? parameter="find">
????????? <forward name="next" path="/actions/pages/find_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/findById"? type="com.allanlxf.struts.actions.UserMappingAction"? parameter="findById">
????????? <forward name="next" path="/actions/pages/findById_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/remove"? type="com.allanlxf.struts.actions.UserMappingAction"? parameter="remove">
????????? <forward name="next" path="/actions/pages/remove_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/modify"? type="com.allanlxf.struts.actions.UserMappingAction"? parameter="modify">
????????? <forward name="next" path="/actions/pages/modify_next.jsp" />
??????? </action>
???????
??????? <action?? path="/mapping/register"? type="com.allanlxf.struts.actions.UserMappingAction"? parameter="register">
????????? <forward name="next" path="/actions/pages/register_next.jsp" />
??????? </action>
???????
??????? <action?? path="/lookup"? type="com.allanlxf.struts.actions.UserLookupAction" parameter="method">
????????? <forward name="login" path="/actions/pages/login_next.jsp" />
????????? <forward name="find" path="/actions/pages/find_next.jsp" />
????????? <forward name="findById" path="/actions/pages/findById_next.jsp" />
????????? <forward name="remove" path="/actions/pages/remove_next.jsp" />
????????? <forward name="modify" path="/actions/pages/modify_next.jsp" />
????????? <forward name="register" path="/actions/pages/register_next.jsp" />
??????? </action>
???????
??????? <action?? path="/dyna/register"? type="com.allanlxf.action.RegisterAction"
?????????????????? name="userForm">
????????? <forward name="success" path="/dyna/success.jsp"/>
??????? </action>
???????
??? </action-mappings>
???
??? <message-resources parameter="com.allanlxf.MessageResources" />
?????????????????
</struts-config>
posted @
2007-04-25 16:12 sunny 閱讀(654) |
評論 (0) |
編輯 收藏
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public abstract class HttpFilter implements Filter
{
??? private FilterConfig config;
???
??? //////////////////////////////////
??? public void init(FilterConfig config) throws ServletException
??? {
??????? this.config = config;
??????? init();
??? }
???
??? public void init() throws ServletException
??? {
??? }
??? ///////////////////////////////
??? public FilterConfig getFilterConfig()
??? {
??????? return config;
??? }
???
??? public String getInitParameter(String name)
??? {
??????? return config.getInitParameter(name);
??? }
???
??? public ServletContext getServletContext()
??? {
??????? return config.getServletContext();
??? }
???
??? public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
??????????????????????????????????????????????? throws IOException, ServletException
??? {
??????? doFilter((HttpServletRequest)request, (HttpServletResponse)response, chain);
??? }
???
??? public abstract void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
??????????????????????????????????????????????? throws IOException, ServletException;
???
??? public void destroy()
??? {
??? }
}
posted @
2007-04-06 16:31 sunny 閱讀(306) |
評論 (0) |
編輯 收藏
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
public class ConnectionFactory
{
/**
oracle?? 分頁
select * from (
select a.*, ROWNUM rn from ( select * from user_info )? a
where ROWNUM<=40 )
where rn >=21
?
*/
??? private static Properties config = new Properties();
???
??? static
??? {
??????? try
??????? {
??????????? InputStream in = ConnectionFactory.class.getClassLoader().getResourceAsStream("dbconfig.properties");
??????????? config.load(in);
??????????? in.close();
??????? }catch(IOException e)
??????? {
??????????? e.printStackTrace();
??????????? throw new ExceptionInInitializerError(e.getMessage());
??????? }
??? }
???
??? public static Connection getConnection()
??? {
??????? if(config.getProperty("jndi-name") != null)
??????? {
??????????? return getJndiConnection();
??????? }
???????
??????? return getDirectConnection();
??? }
???
??? public static Connection getJndiConnection()
??? {
??????? Connection con = null;
??????? try
??????? {
/**context.xml
數據源的配置
<Context>
????? <Resource name="jdbc/oracle" auth="Container" type="javax.sql.DataSource" maxActive="2" maxIdle="1" maxWait="-1"
????? username="openlab" password="open123" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.0.20:1521:tarena"/>
</Context?
*/
??????????? Context ctx = new InitialContext();
??????????? DataSource ds = (DataSource)ctx.lookup("java:comp/env/" + config.getProperty("jndi-name"));
??????????? con = ds.getConnection();
??????? }catch(Exception e)
??????? {
??????????? e.printStackTrace();
??????? }
??????? return con;
??? }
???
??? public static Connection getDirectConnection()
??? {
??????? Connection con = null;
??????? try
??????? {
??????????? Class.forName(config.getProperty("driver"));
??????????? con = DriverManager.getConnection(config.getProperty("dburl") ,config.getProperty("user"), config.getProperty("password"));
??????? }catch(ClassNotFoundException cne)
??????? {
??????????? cne.printStackTrace();
??????? }catch(SQLException sqle)
??????? {
??????????? sqle.printStackTrace();
??????? }
???????
??????? return con;
??? }
???
??? public static void close(ResultSet rs, Statement st, Connection con)
??? {
??????? try
??????? {
??????????? rs.close();
??????? }catch(Exception e)
??????? {
??????? }
???????
??????? try
??????? {
??????????? st.close();
??????? }catch(Exception e)
??????? {
??????? }
???????
??????? try
??????? {
??????????? con.close();
??????? }catch(Exception e)
??????? {
??????? }
??? }
???
??? public static void main(String[] args) throws Exception
??? {
??????? Connection con = ConnectionFactory.getConnection();
??????? System.out.println(con);
??????? con.close();
??? }
}
posted @
2007-04-05 15:30 sunny 閱讀(151) |
評論 (0) |
編輯 收藏