| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 973 人关注过本帖
标题:JSF问题
只看楼主 加入收藏
lgdcky
Rank: 2
等 级:论坛游民
威 望:5
帖 子:576
专家分:18
注 册:2006-8-5
结帖率:33.33%
收藏
 问题点数:0 回复次数:7 
JSF问题
刚写了一个JSF的小程序,问题是我在eclipse上运行时到最后一个页面上的按钮点击后无效!而把代码贴到JB2006上却能正常运行!还有就是JSF标签乱码!我的JSP页面用的是GBK,标签库里的也是用GBK转换的,怎么解决啊??
这个是faces-config.xml的代码!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config xmlns="http://java.sun.com/JSF/Configuration">
<managed-bean>
<managed-bean-name>application</managed-bean-name>
<managed-bean-class>onlineapplication.Application</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/personal.jsp</from-view-id>
<navigation-case>
<from-outcome>experience</from-outcome>
<to-view-id>/experience.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/experience.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/showinfo.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
搜索更多相关主题的帖子: JSF 
2007-04-21 15:05
lgdcky
Rank: 2
等 级:论坛游民
威 望:5
帖 子:576
专家分:18
注 册:2006-8-5
收藏
得分:0 
问题解决了!是程序发病了!突然又好了!

2007-04-21 15:37
风月_无边
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:60
帖 子:2960
专家分:652
注 册:2007-1-19
收藏
得分:0 
还没有看过jsf!

我的网站 http://www.
2007-04-21 22:53
黄袖标
Rank: 4
等 级:贵宾
威 望:13
帖 子:676
专家分:0
注 册:2007-3-22
收藏
得分:0 
我太年轻了吧,还没开始看jsf...

我胡汉三又回来啦!物是人非啊,只有静夜思大大还在。
2007-04-25 10:34
支离破碎
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:737
专家分:0
注 册:2007-1-4
收藏
得分:0 

项目刚用完JSF+IBATAS+SPRING。。。
看有没的空写一个例子放出来了~~~


人生漂泊無依,有如浮萍菱花,隨水飄流,你会在我这里停留吗?
[url=http://51mynet.]http://51mynet.[/url]
2007-04-25 10:40
黄袖标
Rank: 4
等 级:贵宾
威 望:13
帖 子:676
专家分:0
注 册:2007-3-22
收藏
得分:0 
那感情好啊,呵呵,楼上加油.做好了pm我

我胡汉三又回来啦!物是人非啊,只有静夜思大大还在。
2007-04-25 10:42
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
我也打算弄个JSF+EJB3的组合来玩玩
等弄好了发上来

win32汇编
病毒 加密
目前兴趣所在
2007-04-25 20:32
renlong1333
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-5-6
收藏
得分:0 

一个关于课题Subject的JAVABean:
package com.jsfdemo.beans;

public class SubjectBean {
private String sb_id;
private String sb_name;
private String sb_desc;
private String t_name;
private String sb_state;
//--------------------------
public SubjectBean(){

}
//--------------------------
public String getSb_desc() {
return sb_desc;
}
public void setSb_desc(String sb_desc) {
this.sb_desc = sb_desc;
}
public String getSb_id() {
return sb_id;
}
public void setSb_id(String sb_id) {
this.sb_id = sb_id;
}
public String getSb_name() {
return sb_name;
}
public void setSb_name(String sb_name) {
this.sb_name = sb_name;
}
public String getSb_state() {
return sb_state;
}
public void setSb_state(String sb_state) {
this.sb_state = sb_state;
}
public String getT_name() {
return t_name;
}
public void setT_name(String t_name) {
this.t_name = t_name;
}
public SubjectBean(String sb_id,String sb_name,String sb_desc,String t_name,String sb_state ){
this.sb_id = sb_id;
this.sb_name = sb_name;
this.sb_desc = sb_desc;
this.t_name = t_name;
this.sb_state = sb_state;

}
}


一个数据库连接池的类:
package com.jsfdemo.beans;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.sql.*;
import javax.sql.DataSource;
public class DBConnection {

static public Connection dataSource() {
try{
Context ctx = new InitialContext();
if(ctx==null)throw new NamingException ("no initial context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/dbtest");
if(ds==null) throw new NamingException ("no dataSource ");
// Connection con = ds.getConnection();
}catch (NamingException e){

//}catch (SQLException e){

}
return null;
}
}

一个操作数据库的JAVABean:
package com.jsfdemo.beans;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.Vector;
import javax.servlet.jsp.jstl.sql.ResultSupport;
import javax.servlet.jsp.jstl.sql.Result;
import java.sql.SQLException;

public class SbDB {
// private Result AllSubject;
//********************************************
public void addSubject(SubjectBean subject) throws Exception,SQLException{
try{
Connection con =DBConnection.dataSource();
PreparedStatement pst = null;
//try{
pst = con.prepareStatement("insert into subjectInfo(sb_id,sb_name,sb_desc,t_id,sb_state) values(?,?,?,?,?)");
pst.setString(1, subject.getSb_id());
pst.setString(2, subject.getSb_name());
pst.setString(3, subject.getSb_desc());
pst.setString(4, subject.getT_name());
pst.setString(5, subject.getSb_state());
pst.executeUpdate();
//}catch(Exception e){
// e.printStackTrace();
//}
con.close();

}catch(Exception e){
e.printStackTrace();
}

}
}
// ********************************************

一个和JSP界面及JAVABean交互的类:
package com.jsfdemo.beans;
import javax.faces.event.ActionEvent;
import javax.servlet.jsp.jstl.sql.Result;


public class SbManager {

private SubjectBean subjectB = new SubjectBean();
private SbDB sbdb = new SbDB();
//*************************************

public SbManager(){

}
//*************************************

public SubjectBean getSubjectB() {
return subjectB;
}
public void setSubjectB(SubjectBean subjectB) {
this.subjectB = subjectB;
}
public SbDB getSbdb() {
return sbdb;
}

public void setSbdb(SbDB sbdb) {
this.sbdb = sbdb;
}
public String add(){
try{
sbdb.addSubject(subjectB);
}catch(Exception e){
e.printStackTrace();
}
return "addOK";
}

JSP界面:
<%@ page language = "java" contentType = "text/html;charset = gb2312"%>
<%@ taglib uri = "http://java.sun.com/jsf/core" prefix = "f"%>
<%@ taglib uri = "http://java.sun.com/jsf/html" prefix = "h"%>
<html>
<center>
<f:view>
<h:form>

<head>
<title>
add the subject
</title>
</head>
<body>
<h:panelGrid columns = "2">
<h:outputText value = "subjectID"></h:outputText>
<h:inputText value = "#{SbManager.subjectB.sb_id}"></h:inputText>
<h:outputText value = "subjectName"></h:outputText>
<h:inputText value = "#{SbManager.subjectB.sb_name}"></h:inputText>
<h:outputText value = "subjectDesc"></h:outputText>
<h:inputText value = "#{SbManager.subjectB.sb_desc}"></h:inputText>
<h:outputText value = "teacher'sName"></h:outputText>
<h:inputText value = "#{SbManager.subjectB.t_name}"></h:inputText>
<h:outputText value = "subject'sState"></h:outputText>
<h:inputText value = "#{SbManager.subjectB.sb_state}"></h:inputText>
<h:commandButton value = "submit..." action = "#{SbManager.add}"></h:commandButton>
</h:panelGrid>
<h:dataTable value = "#{SbManager.subjectB}" var = "sb" border = "1">
<h:column>
<f:facet name="header">
<h:outputText value = "subjectID"></h:outputText>
</f:facet>
<h:outputText value = "#{sb.sb_id}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "subjectName"></h:outputText>
</f:facet>
<h:outputText value = "#{sb.sb_name}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "subjectDesc"></h:outputText>
</f:facet>
<h:outputText value = "#{sb.sb_desc}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "teacher'sName"></h:outputText>
</f:facet>
<h:outputText value = "#{sb.t_name}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "subject'sState"></h:outputText>
</f:facet>
<h:outputText value = "#{sb.sb_state}"></h:outputText>
</h:column>
</h:dataTable>

</body>
</h:form>
</f:view>
</center>
</html>

其他配置正确(因为我做了测试),我先是把这些代码全部写在一个类里,能实现其功能,但是那样感觉太乱了,所以我把这些代码给分别写在了类里,结果是:
提交后,不显示错误,也不往数据库里插入信息,我已经是到了“山穷水尽”的地步了,实在解决不了这个问题,希望高手帮帮忙,谢谢啊!!!

2007-05-06 15:50
快速回复:JSF问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044076 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved