I have developed a simple Struts 2 project.but when I am trying to retrieve the data from valuestack I am not getting any data. Basically %{} syntax is not recognized while the page is getting served.
My 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>
<form method="get" action="justwork.action">
<input type="text" name="name" value="Xarvis">
<input type="submit" >
</form>
</body>
</html>
My struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<package name="TestFramework" extends="struts-default" >
<action name="justwork" class="org.pranab.actions.OGNLTest">
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
my OGNLTest.java
package org.pranab.actions;
import com.opensymphony.xwork2.ActionContext;
public class OGNLTest {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String execute(){
return "success";
}}
finally my success.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>SUCCESS</h2>
<s:property default="%{name}" value="name"/>
<br>
%{name}
</body>
</html>
Output on Submit:
Is there a requirement of a switch in strust.xml or properties to enable the %{} syntax??