在页面上怎么不能显示${}所共享的内容? 在页面上怎么不能显示${}所共享的内容?而把源码打印出来了?${tip}之前还能得到错误信息,现在把源码打印出来了,愁死了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 和这前有什么变化吗?是不是把jsp改成html了。 什么错误消息?用${sessionScope.tip}试试看 页面引入了<%@ taglib prefix="c" uri= "http://java.sun.com/jstl/core"%>没有?存入:<c:set var="ct" value="<%=request.getContextPath()%>"/>引用:${ct}你那个原因可能就是在作用域内不存在了。 ${tip} 即便是tip为null也应该不会影响页面的,看看是不是其它地方的问题,或者是tip这个变量的问题 这是actionpackage com.amaker.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DispatchAction;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.amaker.form.UserForm;import com.amaker.beans.User;import com.amaker.dao.UserDao;public class UserAction3 extends DispatchAction { UserDao dao; public void setDao(UserDao dao) { this.dao = dao; } public ActionForward login(ActionMapping m, ActionForm f, HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("111"); ApplicationContext context = new ClassPathXmlApplicationContext( "applicationContext.xml"); dao = (UserDao) context.getBean("userDao"); System.out.println("222"); UserForm userForm = (UserForm) f; String username = userForm.getUsername(); String password = userForm.getPassword(); System.out.println("333"); User u = dao.login(username, password); System.out.println("444"); if (u != null) { HttpSession session = request.getSession(); session.setAttribute("userSession", u); System.out.println("55555"); return m.findForward("success"); } else { String msg = "用户名不能为空或空格或用户名、年龄不正确"; request.setAttribute("tip", msg); return m.getInputForward(); } } public ActionForward regedit(ActionMapping m, ActionForm f, HttpServletRequest request, HttpServletResponse response) { ApplicationContext context = new ClassPathXmlApplicationContext( "applicationContext.xml"); dao = (UserDao) context.getBean("userDao"); UserForm userForm = (UserForm) f; String username = userForm.getUsername(); String password = userForm.getPassword(); int age =userForm.getAge(); User u = new User(); u.setUsername(username); u.setPassword(password); u.setAge(age); dao.register(u); HttpSession session = request.getSession(); session.setAttribute("userSession", u); return m.findForward("success"); }}这是页面<%@ page language="java" pageEncoding="GBK"%><%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%> <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <html> <head> <title>JSP for LoginForm form</title> </head> <script type="text/javascript"> function invoke(method){ var f = document.forms[0]; f.action="<%=path%>/user.do?action="+method; f.submit(); } </script> ${sessionScope.tip} <body> <html:messages id="" name="tip" ></html:messages> <html:form action="/user?action=login"> username : <html:text property="username" value="admin" alt="username" maxlength="20" title="NAME"/><html:errors property="username"/><br/> password : <html:password property="password" value="password" alt="password" maxlength="20" title="PASSWORD"/><html:errors property="password"/><br/> <%--<input type="button" value="login" onclick="invoke('login')"/> <input type="button" value="regedit" onclick="invoke('regedit')"/> --%> <html:submit/><html:cancel/> </html:form> </body></html> 我解决了,我用的是JAVA J2EE 下面的容器不支持EL表达式 在 web.xml里看容器版本.<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_ID" version="2.4" 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"> 如果是2.4一下的版本,可以在页面显示的写 el="true" 你有没有加STRUTS的标签啥,好好看看啊 在页面上导入下面的代码 <%@ page isELIgnored="false" %> 可能是版本的问题吧,我创建的时候都用 J2EE 5.0 它默认支持的 struts 2 乱码问题 网站 安全性和访问路径问题! java socket 异步 双工 长连接 空指针问题,,,菜鸟在线等 一个简单邮箱开发问题 tomahawk tree2的节点状态保持问题 span标签里何控制文字在页面显示的位置(如在页面的左边显示) struts2.x的推出能让所有的struts1.x的市场过渡到struts2.x吗 jsp页面全选怎么做?&hibernate+sruts 分页 外企招聘熟悉J2ME的Java程序员及有志于J2ME的人才、c/c++程序员!! 有关logic:iterate的错误 Swing
存入:
<c:set var="ct" value="<%=request.getContextPath()%>"/>
引用:
${ct}你那个原因可能就是在作用域内不存在了。
package com.amaker.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.amaker.form.UserForm;
import com.amaker.beans.User;
import com.amaker.dao.UserDao;public class UserAction3 extends DispatchAction {
UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
} public ActionForward login(ActionMapping m, ActionForm f,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("111");
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
dao = (UserDao) context.getBean("userDao");
System.out.println("222");
UserForm userForm = (UserForm) f;
String username = userForm.getUsername();
String password = userForm.getPassword();
System.out.println("333");
User u = dao.login(username, password);
System.out.println("444");
if (u != null) {
HttpSession session = request.getSession();
session.setAttribute("userSession", u);
System.out.println("55555");
return m.findForward("success");
} else {
String msg = "用户名不能为空或空格或用户名、年龄不正确";
request.setAttribute("tip", msg);
return m.getInputForward();
}
} public ActionForward regedit(ActionMapping m, ActionForm f,
HttpServletRequest request, HttpServletResponse response) { ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
dao = (UserDao) context.getBean("userDao");
UserForm userForm = (UserForm) f;
String username = userForm.getUsername();
String password = userForm.getPassword();
int age =userForm.getAge();
User u = new User();
u.setUsername(username);
u.setPassword(password);
u.setAge(age);
dao.register(u);
HttpSession session = request.getSession();
session.setAttribute("userSession", u);
return m.findForward("success");
}
}
这是页面
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<title>JSP for LoginForm form</title>
</head> <script type="text/javascript">
function invoke(method){
var f = document.forms[0];
f.action="<%=path%>/user.do?action="+method;
f.submit();
}
</script>
${sessionScope.tip}
<body>
<html:messages id="" name="tip" ></html:messages>
<html:form action="/user?action=login"> username : <html:text property="username" value="admin" alt="username" maxlength="20" title="NAME"/><html:errors property="username"/><br/>
password : <html:password property="password" value="password" alt="password" maxlength="20" title="PASSWORD"/><html:errors property="password"/><br/>
<%--<input type="button" value="login" onclick="invoke('login')"/>
<input type="button" value="regedit" onclick="invoke('regedit')"/> --%>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
<web-app id="WebApp_ID" version="2.4"
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">
<%@ page isELIgnored="false" %>
可能是版本的问题吧,我创建的时候都用
J2EE 5.0 它默认支持的