2008-05-09
ssh2整合
此项目增删改查基本要的都有了,集合了国际化,校验框架加上无法提交,还需要研究
Action类
测试类
struts.xml
请问类级的国际化没办法调用什么原因
Action类
package com.struts.action;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.hibernate.po.UserTab;
import com.hibernate.service.IUserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport {
private IUserService dao;
public IUserService getDao() {
return dao;
}
public void setDao(IUserService dao) {
this.dao = dao;
}
private UserTab user;
public UserTab getUser() {
return user;
}
public void setUser(UserTab user) {
this.user = user;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
try {
System.out.println("find");
Map request = (Map) ActionContext.getContext().get("request");
request.put("list", dao.findAll());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return SUCCESS;
}
public String save() throws Exception {
try {
dao.save(user);
System.out.println("save");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return SUCCESS;
}
public String see() throws Exception {
try {
user = dao.findById(user.getId());
System.out.println("see");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return SUCCESS;
}
public String delete() throws Exception {
try {
dao.delete(user);
System.out.println("delete");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return SUCCESS;
}
public String update() throws Exception {
try {
dao.update(user);
System.out.println("update");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return SUCCESS;
}
}
测试类
import java.util.Iterator;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hibernate.impl.UserService;
import com.hibernate.po.UserTab;
public class Test {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"applicationContext.xml");
// UserTab user = new UserTab();
UserService um = (UserService) ctx.getBean("userService");
// user.setFirstname("张");
// user.setLastname("三");
// um.save(user);
Iterator it = um.findAll().iterator();
while (it.hasNext()) {
UserTab u = (UserTab) it.next();
System.out.println(u.getFirstname());
}
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="user" extends="struts-default">
<action name="find" class="userAction">
<result>/list.jsp</result>
</action>
<action name="save" class="userAction" method="save">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="token" />
<result>/list.jsp</result>
<result name="invalid.token">save.jsp</result>
<result name="input">/save.jsp</result>
</action>
<action name="see" class="userAction" method="see">
<result>/update.jsp</result>
<result name="input">/update.jsp</result>
</action>
<action name="update" class="userAction" method="update">
<result type="redirect">find.action</result>
<result name="input">/index.jsp</result>
</action>
<action name="delete" class="userAction" method="delete">
<result type="redirect">find.action</result>
<result name="input">/index.jsp</result>
</action>
</package>
</struts>
请问类级的国际化没办法调用什么原因
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 1193 次

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
在ASP.NET 2.0中实现URL ...
不知道这样的方式和ISAPI的插件模式,在效率上有什么差别。
-- by 风中独火 -
在ASP.NET 2.0中实现URL ...
<system.web> <urlMappings enabl ...
-- by hunter001201 -
向页面传值接收不到
没人知道吗`````````````````````问题已经解决`````
-- by litoueva






评论排行榜