Hallo,
i m trying to send a hello world with strus2. but it return empty page.
http:// www.flickr.com/photos/56834047@N06/5243835760/in/photostream /lightbox/
Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="testStruts2" extends="struts-default" >
<action name="StevStruts" class="testStruts2.StevStruts">
<result>index.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
index.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2>qsdf<s:property value="message" /></h2>
</body>
</html>
.java:
package testStruts2;
import com.opensymphony.xwork2.ActionSupport;
public class StevStruts extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Struts is up and running ...";
public String execute() throws Exception {
setMessage(MESSAGE);
return SUCCESS;
}
private String message;
public void setMessage(String message){
this.message = message;
}
public String getMessage() {
return message;
}
}
http:// www.flickr.com/photos/56834047@N06/5243835732/in/photostream /lightbox/
question:
1.is the name of package in struts.xml must be the same name package in.java (green color in image above) ?
2.is the name of action in struts.xml must be the same name in class dans .java (cblue color in image above) ?
thanx in advance,
Stev
[Updated on: Thu, 09 December 2010 19:23]
Report message to a moderator