Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / Поможите с struts и servlet / 2 сообщений из 2, страница 1 из 1
25.06.2007, 14:01:59
    #34617358
yohann
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Поможите с struts и servlet
Уважаемые ГУРУ есть код, но почему то при отладке в браузере выдаётся сообщение что ресурс не доступен исходники прилагаю!!!
Модератор: Используйте кнопку SRC для форматирования текста
web.xml:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">    
    
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        <init-param>
          <param-name>actions</param-name>  
          <param-value>actions</param-value>
        </init-param>
    </filter>
    
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <session-config>
        <session-timeout>
             30 
        </session-timeout>
    </session-config>
    <welcome-file-list>
	<welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>
</web-app>
index.jsp:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib prefix="struts" uri="META-INF/struts-tags.tld" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Запрос</title>
    </head>
    <body>

    <h1>Запрос</h1>
          <struts:form  action="LoginAction" method="post">
              <struts:textfield label="UserName" name="username"/>
              <struts:password label="Password" name="password"/>
              <struts:submit label="Go!!!"/>
          </struts:form>
      </body>
  </html>
struts.xml:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">    
    
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        <init-param>
          <param-name>actions</param-name>  
          <param-value>actions</param-value>
        </init-param>
    </filter>
    
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <session-config>
        <session-timeout>
             30 
        </session-timeout>
    </session-config>
    <welcome-file-list>
	<welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>
</web-app>
LoginAction.java:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
 package  actions;
 import  java.io.*;
 import  java.util.*;
 import  java.util.logging.*;
 import  javax.servlet.http.*;
 import  javax.servlet.*;
 import  com.opensymphony.xwork2.*;
 import  org.apache.struts2.ServletActionContext;
 import  execDB.QueryDB;

 public   class  LoginAction  extends  ActionSupport
{
     protected  String username;
     protected  String password;
     protected  String actionName="";
     public  PrintStream out;
    
    /** Creates a new instance of LoginAction */
     public  String LoginAction()  throws  Exception,IOException
    {
    Map<String,Object> session=(Map<String,Object>)(ActionContext.getContext().getSession());
    String actionName=(String)ActionContext.getContext().getName();
    QueryDB QueryMy= new  QueryDB();
     try 
    {
         if  (actionName.equals("loginAction"))
        {
            QueryMy.execute(username,password,out);
             return  "success";
        }
         else 
        {
             return  "notsuccess";
        }
    }
     catch  (Throwable ex)
    {
         this .addActionError(ex.getMessage());
         return  "notsuccess";
    }
    }

     public  String getUsername() {
         return  username;
    }

     public   void  setUsername(String username) {
         this .username = username;
    }

     public  String getPassword() {
         return  password;
    }

     public   void  setPassword(String password) {
         this .password = password;
    }
    
}
...
Рейтинг: 0 / 0
26.06.2007, 11:41:20
    #34619517
yohann
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Поможите с struts и servlet
тема закрыта сам разобрался!!! оказалось проблемы в библиотеках!!!
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / Поможите с struts и servlet / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]