Значения базы данных не отображаются на веб-странице?JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Значения базы данных не отображаются на веб-странице?

Сообщение Anonymous »

В своем проекте я использую Struts 2 + Hibernate. Хотя я относительно новичок в этой области. Я могу получить необходимые значения в коде Java, но не могу получить их на странице JSP.
Это мой файл struts.xml:
Это мой файл struts.xml:
Strong>






listTweet


/showTweet.jsp




Это моя страница JSP:





Home Page.






Welcome



Tweet:





Show Tweets:







Из JSP при нажатии кнопки «Показать твит» он должен сопоставиться с listTweet в struts.xml и должен перейти к методу list() класса TweetAction.java.
TweetAction.java:
package com.vaannila.web;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.vaannila.dao.TweetDAO;
import com.vaannila.dao.TweetDAOImpl;
import com.vaannila.dao.UserDAO;
import com.vaannila.dao.UserDAOImpl;
import com.vaannila.domain.Tweet;
import com.vaannila.domain.User;

public class TweetAction extends ActionSupport implements ModelDriven,SessionAware{

private User user = new User();
private List userList = new ArrayList();
private UserDAO userDAO = new UserDAOImpl(); //UserDAO interface, UserDAOImpl implements it.
private boolean isAuthentic = false;

private Tweet tweet = new Tweet();
private List tweetList = new ArrayList();
//TweetDAO interface, TweetDAOImpl implements it.
private TweetDAO tweetDAO = new TweetDAOImpl();

public Tweet getModel() {
// TODO Auto-generated method stub
return tweet;
}

public String list()
{
System.out.println("inside list method");
tweetList = tweetDAO.listTweet();
System.out.println("exiting list method");
return SUCCESS;
}

public String add()
{
System.out.println("inside put message");
tweet.setUser_id(user.getUser_id());
System.out.println(user.getUser_id());
tweetDAO.saveTweet(tweet);
return SUCCESS;
}

public String showTweet()
{
System.out.println("inside list method");
tweetList = tweetDAO.listTweet();
System.out.println("exiting list method");
return SUCCESS;
}
}

Вот интерфейс TweetDAO.java:
package com.vaannila.dao;

import java.util.List;

import com.vaannila.domain.Tweet;

public interface TweetDAO {

public void saveTweet(Tweet tweet);
public List listTweet();

}

Вот TweetDAOImpl:
package com.vaannila.dao;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
import com.vaannila.domain.Tweet;

public class TweetDAOImpl implements TweetDAO,SessionAware {

@SessionTarget
Session session;
@TransactionTarget
Transaction transaction;
Map session1;

public void saveTweet(Tweet tweet) {
try {
System.out.println("Update successful..");
session.save(tweet);
transaction.commit();
} catch (Exception e) {
transaction.rollback();
e.printStackTrace();
}
}

public void setSession(Map session) {
session1 = session;

}

public List listTweet() {
List courses = null;
try
{
System.out.println("entered dao impl");
SQLQuery query = session.createSQLQuery("select message,created from tweet");
courses=query.list();
System.out.println("dao impl "+courses);

} catch (Exception e)
{
System.out.println("sorry entered exception");
e.printStackTrace();
}
return courses;
}
}

Я могу получить ценность на курсах. При использовании System.out.println("dao impl "+courses); выдается следующий результат:
dao impl [[Ljava.lang.Object;@3d2178, [Ljava.lang.Object;@1607a8a, [Ljava.lang.Object;@10d04fc, [Ljava.lang.Object;@1c27660, [Ljava.lang.Object;@1e99fae]

Значит, на курсах хоть что-то есть. Но на странице JSP это происходит в цикле else.
Где ошибка?
Это моя трассировка стека:
Dec 01, 2014 4:36:09 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre7/bin/client;C:/Program Files (x86)/Java/jre7/bin;C:/Program Files (x86)/Java/jre7/lib/i386;D:\app\trg\product\11.2.0\client_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CheckPoint\File Encryption\Program\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies;C:\Program Files (x86)\Java\jdk1.7.0_45\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;D:\New folder\eclipse;;.
Dec 01, 2014 4:36:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsIntegHib' did not find a matching property.
Dec 01, 2014 4:36:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 01, 2014 4:36:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 474 ms
Dec 01, 2014 4:36:09 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 01, 2014 4:36:09 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/stand ... tedTaglibs is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Dec 01, 2014 4:36:09 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Dec 01, 2014 4:36:10 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [296] milliseconds.
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/stand ... tedTaglibs is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Dec 01, 2014 4:36:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
Dec 01, 2014 4:36:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 01, 2014 4:36:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 01, 2014 4:36:12 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3311 ms
Dec 01, 2014 4:36:15 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Dec 01, 2014 4:37:43 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/StrutsIntegHib] has started
Dec 01, 2014 4:37:43 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/StrutsIntegHib] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@31c2df]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@f0d523]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 01, 2014 4:37:43 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/StrutsIntegHib] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@31c2df]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@13929d6]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 01, 2014 4:37:43 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/StrutsIntegHib] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@31c2df]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1b964b7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/stand ... tedTaglibs is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Dec 01, 2014 4:37:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
Dec 01, 2014 4:37:45 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/StrutsIntegHib] is completed


Подробнее здесь: https://stackoverflow.com/questions/272 ... he-webpage
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»