struts.xml的配置:
<action name="NewscontentAction" class="com.news.action.NewscontentAction" >
<result name="show">/index.jsp</result>
<result name="error">/error.jsp</result>
</action>
index.jsp的代码:
<div class="column">
<ul class="latestnews">
<s:action name="NewscontentAction!listHotNewscontent" executeResult=“true” />
<s:iterator value="#session.hotnewscontent" status="list">
<li><img src="images/6.jpg" alt="" />
<p><strong><a href="#"><s:property value="newstitle"/></a></strong><s:property value="content" /></p>
</li>
</s:iterator>
</ul>
</div>
NewscontentAction.java代码:
package com.news.action;
import java.util.List;
import java.util.Map;
import com.news.dao.NewscontentDAO;
import com.news.dao.impl.NewscontentDAOImpl;
import com.news.model.Newscontent;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class NewscontentAction extends ActionSupport{
private int id;
private Newscontent newscontent;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Newscontent getNewscontent() {
return newscontent;
}
public void setNewscontent(Newscontent newscontent) {
this.newscontent = newscontent;
}
public String execute() throws Exception
{
return SUCCESS;
}
public String listHotNewscontent() throws Exception
{
String result="";
NewscontentDAO newscontentDAO=new NewscontentDAOImpl();
List list=newscontentDAO.searchNewscontent();
if(list==null)
{
result="error";
}
else
{
ActionContext act=ActionContext.getContext();
Map map=act.getSession();
map.put("hotnewscontent", list);
result="show";
}
return result;
}
}
本人想实现的效果就是访问index.jsp的同时,加载NewscontentAction中的listHotNewscontent方法,但是运行tomcat,访问http://localhost:8080/news1/index.jsp的时候,老是提示:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
应该是<s:action>哪里用错了,求大侠指点。
<s:action name="NewscontentAction!listHotNewscontent" executeResult=“true” /> 标点符号有问题